简体   繁体   English

Windows事件日志的时间格式是什么?

[英]What is the time format of Windows Event Log?

Which format does this stirng 2010-06-19T06:28:01.077148400Z belong to? 这种激荡的格式2010-06-19T06:28:01.077148400Z属于哪种?

It represents 6/19/2010 11:58:01 AM. 它代表6/19/2010 11:58:01 AM。

I tried parsing the string to DateTime.Parse() and the DateTime object represents the above time. 我尝试将字符串解析为DateTime.Parse(),DateTime对象表示上述时间。 Now I want to convert that DateTime object to the format once again. 现在我想再次将该DateTime对象转换为该格式。 How can I do that? 我怎样才能做到这一点?

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 . 根据您的用户信息,您看起来像是在印度时区 - 新德里区比UTC早5小时30分钟。 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. 日期/时间字符串末尾的“Z”表示UTC,这是有道理的:6:28 UTC是您所在时区的11:58。

You can take a local DateTime and convert it to UTC using ToUniversalTime - but if you want to get the current time, you can just use DateTime.UtcNow to start with. 您可以使用本地DateTime并使用ToUniversalTime将其转换为UTC - 但如果您想获取当前时间,则可以使用DateTime.UtcNow开始。

Once you've got a DateTime in UTC, this format string would format it in the same way: 一旦你有了UTC的DateTime ,这个格式字符串将以相同的方式格式化它:

yyyy-MM-ddTHH:mm:ss.fffffff00K

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. 这些被硬编码为0,因为DateTime精度不超过十分之一微秒,而您的样本字符串则将其缩小到一纳秒。

For example: 例如:

DateTime now = DateTime.UtcNow;
string s = now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff00K",
                        CultureInfo.InvariantCulture);

creates something like this: 创建这样的东西:

2010-06-19T13:57:15.885578200Z

Looks like Universaltime to me. 对我而言看起来像Universaltime

Grz, Kris. 格兹,克里斯。

This looks like the representation of a DateTime using the Round-trip ("O", "o") Format Specifier : 这看起来像使用往返(“O”,“o”)格式说明符的DateTime表示:

var s = "2010-06-19T06:28:01.077148400Z";

var dt = DateTime.Parse(s, null, DateTimeStyles.RoundtripKind);

Console.WriteLine(dt.ToString("o"));  //  prints "2010-06-19T06:28:01.0771484Z"

它看起来像往返格式的 UTC 格式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM