Windows 事件日志的时间格式是什么?
这个stirng 2010-06-19T06:28:01.077148400Z
属于哪种格式?
它代表 6/19/2010 11:58:01 AM。
我尝试将字符串解析为 DateTime.Parse() ,并且 DateTime 对象代表上述时间。现在我想再次将该 DateTime 对象转换为该格式。我怎样才能做到这一点?
Which format does this stirng 2010-06-19T06:28:01.077148400Z
belong to?
It represents 6/19/2010 11:58:01 AM.
I tried parsing the string to DateTime.Parse() and the DateTime object represents the above time. Now I want to convert that DateTime object to the format once again. How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据您的用户信息,您似乎位于印度时区 - 新德里时区比UTC早 5 小时 30 分钟。日期/时间字符串末尾的“Z”表示 UTC,这是有道理的:6:28 UTC 是您所在时区的 11:58。
您可以获取本地
DateTime
并使用ToUniversalTime
将其转换为 UTC - 但如果您想获取当前时间,只需使用DateTime.UtcNow
代码> 首先。一旦您获得了 UTC 格式的
DateTime
,此格式字符串就会以相同的方式对其进行格式化:这与往返格式非常相似,只是末尾多了两个零。这些被硬编码为 0,因为
DateTime
的精度不超过十分之一微秒,而您的示例字符串的精度则低至纳秒。例如:
创建这样的东西:
Given your user information, it looks like you're in an Indian time zone - the New Delhi zone is 5 hours and thirty minutes ahead of UTC. The "Z" at the end of the date/time string indicates UTC, which makes sense: 6:28 UTC is 11:58 in your time zone.
You can take a local
DateTime
and convert it to UTC usingToUniversalTime
- but if you want to get the current time, you can just useDateTime.UtcNow
to start with.Once you've got a
DateTime
in UTC, this format string would format it in the same way:This is very similar to the round-trip format, just with the extra two zeroes at the end. Those are hard-coded to 0 as
DateTime
doesn't have precision beyond a tenth of a microsecond, whereas your sample string has it down to a nanosecond.For example:
creates something like this:
对我来说看起来像 Universaltime 。
格兹,克里斯。
Looks like Universaltime to me.
Grz, Kris.
这看起来像使用 往返 ("O ", "o") 格式说明符:
This looks like the representation of a DateTime using the Round-trip ("O", "o") Format Specifier:
它看起来像是往返格式 的 UTC 格式。
It looks like UTC formatted in round-trip format.