Saturday, 15 January 2011

c# - Convert a string date format "dd/MM/yyyy" into "dd-month-yyyy" -


here, shift.frmfromdate = '{1/1/2015 12:00:00 AM}'. However, I want the format 1-January 2015

  secure void txttodate_TextChanged (object sender, EventArgs e) {shift.frmfromdate = Convert.ToDateTime (txtfromdate.Text); Shift.frmtodate = Convert toDateTime (txttodate.Text); Gvshiftschdule.DataSource = shifthandler.shiftview (shift); Gvshiftschdule.DataBind (); }  

convert string to your needs in DT The date of input is.

Leading without zero / month / month number

String.Format ("{0: M / d / yyyy}", dt ); // "3/9/2008"

string.format ("{0: MM / dd / Yyyy}", dt); // "03/09/2008"

day / month name

string format ("{0: DDD, MMM D, YYYY} ", DT); // "Sun, March 9, 2008"

string.format ("{0: Dddd, MMMM d, yyyy}", dt); // "Sunday, March 9, 2008"

two / four digit year

string.format ("{0 : MM / dd / yy} ", dt); // "03/09/08"

string format ("{0: MM / dd / yyyy}", dt); // "03/09/2008"


No comments:

Post a Comment