C # parse GMT date string to DateTime

I use the http://www.eyecon.ro/bootstrap-datepicker/ plugin to select a date, and after selecting the date I get, for example.Fri Nov 01 2013 00:00:00 GMT+0100

1) Why do I get this date format if I configured the plugin with the format yyyy-mm-dd?

2) How to parse Fri Nov 01 2013 00:00:00 GMT+0100in a DataTime using a format yyyy-mm-dd?

+4
source share
1 answer

You can use the format "ddd MMM dd yyyy HH:mm:ss 'GMT'K"with DateTime.ParseExact:

string s = "Fri Nov 01 2013 00:00:00 GMT+0100";
DateTime dt = DateTime.ParseExact(s, "ddd MMM dd yyyy HH:mm:ss 'GMT'K", CultureInfo.InvariantCulture);
Console.WriteLine(dt);

The output will be:

10/31/2013 11:00:00 PM

Here . demonstration

For more information, browse:

+8
source

All Articles