Possible Duplicate:
Parse string to DateTime in C#
I am getting date and time returned from an API as a string in the following format:
Mon Aug 13 15:04:51 -0400 2012
Does anyone have experience with how I can turn this into a DateTime?
Possible Duplicate:
Parse string to DateTime in C#
I am getting date and time returned from an API as a string in the following format:
Mon Aug 13 15:04:51 -0400 2012
Does anyone have experience with how I can turn this into a DateTime?
How about
DateTime dt = DateTime.ParseExact("Mon Aug 13 15:04:51 -0400 2012",
"ddd MMM dd HH:mm:ss K yyyy",
CultureInfo.InvariantCulture)
You should read about Custom Date and Time Format Strings
Have a look at the DateTime.Parse method.
Or if you are not sure that the parsing will succeed, use the DateTime.TryParse method.
For unconventional date and time strings use the DateTime.ParseExact method.