为什么不能DateTime.Parse解析UTC的日期 [英] Why can't DateTime.Parse parse UTC date

查看:112
本文介绍了为什么不能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'.

这篇关于为什么不能DateTime.Parse解析UTC的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆