I have strings in the format
Mar 25 2013 6:30PM
and I want to convert them to datetime objects in the format
2013-03-25 18:30:00
how would I go about doing this?
I have strings in the format
Mar 25 2013 6:30PM
and I want to convert them to datetime objects in the format
2013-03-25 18:30:00
how would I go about doing this?
Try this
DateTime dt
CultureInfo provider = CultureInfo.InvariantCulture;
System.Globalization.DateTimeStyles style = DateTimeStyles.None;
DateTime.TryParseExact("Mar 25 2013 6:30PM", "MMM d yyyy h:mtt", provider, style, out dt);
you can use:
var date = DateTime.Parse("Mar 25 2013 6:30PM");
Console.WriteLine(date.ToString()); /*This will output the date in the required format */