ASP.NET C# convert date format to yyyy-MM-dd HH:mm:ss

For me its wirking with following:

fielddata4 = ’26/05/2011′
DateTime dt = DateTime.Parse(fielddata4);
string date = Change_to_rangevalidator(dt);

public static string Change_to_rangevalidator(DateTime dt)
//string strTest = stringTest();
string format = “yyyy-MM-dd HH:mm:ss”;
string date = dt.ToString(format, DateTimeFormatInfo.InvariantInfo);
return date;

in vb:

Dim tdate As String
tdate = DateTime.Now.ToString(“MMddyy”)    ****dd and yy need to be in small. Not caps


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s