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

查看:26
本文介绍了为什么 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天全站免登陆