0

Hi
i need to convert date format 16/1/2010 10:10:2011 AM to 1/16/2010 10:10:2011 AM after that i need to put values to database too as datetime datatype.Can you please help.


many thanks in advance

4
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by jijo cleetus
0

This is how you can convert into both cases:

string ss2 = DateTime.Now.ToString("dd/MM/yyyy hh:mm.ss tt", System.Globalization.CultureInfo.InvariantCulture);
 string ss3 = DateTime.Now.ToString("MM/dd/yyyy hh:mm.ss tt", System.Globalization.CultureInfo.InvariantCulture);
0

This is how you can convert into both cases:

string ss2 = DateTime.Now.ToString("dd/MM/yyyy hh:mm.ss tt", System.Globalization.CultureInfo.InvariantCulture);
 string ss3 = DateTime.Now.ToString("MM/dd/yyyy hh:mm.ss tt", System.Globalization.CultureInfo.InvariantCulture);

Hi,

many thanks for the reply

but my issue is server time is in UK standard , it displays time as "MM/dd/yyyy hh:mm.ss tt" format. i saved this value into string.and converted it to "dd/MM/yyyy hh:mm.ss tt" format.then i cant convert this string value back to datetime datatype.

0

Try this conversation:

DateTime dDate = DateTime.Now;
string sDate = dDate.ToString("dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB"); //dd/MM/yyyy
DateTime newDate = DateTime.Parse(sDate);

Edited by Mitja Bonca: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.