Why can't .NET parse a date string with a timezone?

.NET throws an exception trying to parse a datetime string in this format:

Fri, 10 Oct 2008 00:05:51 CST

Convert.ToDateTime ("Fri, 10 Oct 2008 00:05:51 CST") throws an exception:

The string was not recognized as valid DateTime. There is an unknown word starting with index 26

Character 26 is obviously the beginning of "CST"

In a quick test, PHP and javascript can parse this string into a date without a problem. Is .NET just unsuccessful or is there a reasonable explanation?

+3
source share
2 answers

http://msdn.microsoft.com/en-us/library/ey1cdcx8.aspx

You need to use the overloaded DateTime.Parse to accurately analyze time zones.

+2

, ParseExact .

0

Source: https://habr.com/ru/post/1698158/


All Articles