为什么 DateTime.Parse 不能解析 UTC 日期

为什么 DateTime.Parse 不能解析 UTC 日期

问题描述:

为什么不能解析这个:

DateTime.Parse("Tue, 1 Jan 2008 00:00:00 UTC")

无法解析该字符串,因为UTC"不是有效的时区指示符.

It can't parse that string because "UTC" is not a valid time zone designator.

UTC 时间是通过在时间字符串的末尾添加一个Z"来表示的,因此您的解析代码应如下所示:

UTC time is denoted by adding a 'Z' to the end of the time string, so your parsing code should look like this:

DateTime.Parse("Tue, 1 Jan 2008 00:00:00Z");

来自 维基百科关于 ISO 8601 的文章

如果时间是 UTC,请添加一个Z"直接在没有时间之后空间.'Z' 是区域指示符零 UTC 偏移量.09:30 UTC"是因此表示为09:30Z"或0930Z".14:45:15 UTC"将是14:45:15Z"或144515Z".

If the time is in UTC, add a 'Z' directly after the time without a space. 'Z' is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z".

UTC 时间也称为祖鲁"时间,因为祖鲁语"是北约的拼音'Z' 的字母词.

UTC time is also known as 'Zulu' time, since 'Zulu' is the NATO phonetic alphabet word for 'Z'.