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


here, shift.frmfromdate ='{1/1/2015 12:00:00 am}'. but, want format 1-jan-2015

protected 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 requirements. here dt contains input date.

month/day numbers without/with leading zeroes

string.format("{0:m/d/yyyy}", dt); // "3/9/2008"

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

day/month names

string.format("{0:ddd, mmm d, yyyy}", dt); // "sun, mar 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"


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -