为什么不能DateTime.Parse解析UTC日期 [英] Why can't DateTime.Parse parse UTC date
问题描述
的为什么的不能将它解析如下:
DateTime.Parse(星期二,2008年1月1日00:00:00 UTC)
它无法分析该字符串,因为UTC不是一个有效的时区指示符。
UTC时间是通过增加一个Z的时间字符串的结尾表示,所以你解析code应该是这样的:
DateTime.Parse(星期二,2008年00年1月1日:00:00Z);
从ISO上的维基百科文章8601
如果时间是UTC,添加一个'Z'
的情况下直接涉及的时间之后
空间。 Z是用于区指示符
零UTC时差。 UTC 09:30是
因此,重新psented为$ P $09:30Z或
0930Z。 14点45分15秒UTC将是
14:45:15Z或144515Z
UTC时间也被称为祖鲁'的时候,
因为祖鲁是北约拼音
为Z字母词。
块引用>Why can't it parse this:
DateTime.Parse("Tue, 1 Jan 2008 00:00:00 UTC")
解决方案It can't parse that string because "UTC" is not a valid time zone designator.
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");
From the Wikipedia article on ISO 8601
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 time is also known as 'Zulu' time, since 'Zulu' is the NATO phonetic alphabet word for 'Z'.
这篇关于为什么不能DateTime.Parse解析UTC日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!