这个时间值是什么格式?

发布于 2024-08-03 05:55:36 字数 337 浏览 8 评论 0 原文

我有一个以“20090219000000.000000+480”格式指定时间的 WMI 查询

有人能告诉我这是什么格式吗?.NET 是否有任何内置功能可以使用它?

编辑

该时间值来自我找到的示例查询。我不知道用什么时间值来生成它。我只需要能够将时间值转换为这种格式。

编辑2

我发现这次是在CIM_DATETIME 格式。

I have a WMI query that specifies time in this format '20090219000000.000000+480'

Can someone tell me what format this is, and does .NET have any built-in functionality to work with it?

EDIT

This time value is from a sample query that I found. I don't know what time value was used to generate it. I just need to be able to convert a time value to this format.

EDIT 2

I found out this time is in CIM_DATETIME format.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

谎言月老 2024-08-10 05:55:36

正如其他人所建议的,该字符串是 DATETIME MOF 数据的示例类型。它是一个固定长度的字符串,您可以找到有关其结构的详细信息 System.Management 命名空间 访问 WMI 和一个它的类是 ManagementDateTimeConverter 类,它有助于使用WMI 日期时间值。

以下是如何使用这一切:

var time_written = System.Management.ManagementDateTimeConverter.ToDateTime((string)result.GetPropertyValue("TimeWritten")); 

As others have suggested the string is an example of DATETIME MOF data type. It is a fixed-length string and you can find details about its structure here. .Net uses System.Management namespace to access WMI and one of its classes is ManagementDateTimeConverter class which facilitates working with WMI datetime values.

Here is how you use all this:

var time_written = System.Management.ManagementDateTimeConverter.ToDateTime((string)result.GetPropertyValue("TimeWritten")); 
挽清梦 2024-08-10 05:55:36

这看起来像一个没有任何分隔符的标准日期时间字符串:

'20090219000000.000000+480'

'yyyyMMddhhmmss.ffffff+480'

yyyy - 四位数的年份。
MM - 数字月份。个位数月份有一个前导零。
dd - 一个月中的哪一天。个位数的天数有一个前导零。
hh - 12 小时制的小时。单位数小时有一个前导零。 (也可以是 HH,即 24 小时制的小时,单位数小时有前导零。)
毫米 - 分钟。单位数分钟有一个前导零。
ffffff - 六位精度的秒分数。

“+480”很可能是一个时区指示器,尽管不是标准的。通常,时区以 UTC 时间表示为小时(或小时和分钟)。这看起来可能只有几分钟。因此,没有标准格式说明符。

.NET 中的 DateTime 类是您用来处理该值的类。但是,您可能希望在将剩余字符串解析为实际的 DateTime 变量之前去掉“+480”部分。然后,您可以将其调整为正确的时区或提前执行时区转换(从分钟到小时/分钟)并将“+480”更改为正确的时区表示,然后将整个内容传递给 DateTime.Parse。

This looks like a standard date time string without any separators:

'20090219000000.000000+480'

'yyyyMMddhhmmss.ffffff+480'

yyyy - The year in four digits.
MM - The numeric month. Single-digit months have a leading zero.
dd - The day of the month. Single-digit days have a leading zero.
hh - The hour in a 12-hour clock. Single-digit hours have a leading zero. (This could also be HH, which is the hour in a 24-hour clock with single-digit hours having a leading zero.)
mm - The minute. Single-digit minutes have a leading zero.
ffffff - The fraction of a second in six-digit precision.

The "+480" is most likely a timezone indicator, although not a standard one. Normally time zones are represented as hours (or hours and minutes) from UTC. This appears to probably only be minutes. As such, there is no standard format specifier.

The DateTime class in .NET is what you would use to work with this value. However, you would probably want to take the "+480" portion off before parsing the remaining string in to an actual DateTime variable. You can then adjust it to the correct timezone or perform the timezone conversion (from minutes to hours/minutes) ahead of time and change the "+480" to the correct timezone representation and then pass the whole thing to DateTime.Parse.

内心荒芜 2024-08-10 05:55:36

请查看此链接。只要看一下,我就会说它的格式是 yyyyMMddhhmmss。[一大堆“f”字符]。

Take a look at this link. Just by looking I'd say it's in a format of yyyyMMddhhmmss.[a whole bunch of 'f' characters].

风吹雨成花 2024-08-10 05:55:36

如果您告诉我们它代表的日期将会有所帮助。开头的 2009 表明它可能是 YYYYMMDDHHMMSS.FFFFFF+TZ

(F= 秒的小数部分,TZ 与 UTC 的分钟差,所以这里是 6 小时)

It would help if you told us was date it represented. It 2009 at the start suggests it may be YYYYMMDDHHMMSS.FFFFFF+TZ

(F= fraction of seconds, and TZ being difference from UTC in minute, so here, 6 hours)

谈下烟灰 2024-08-10 05:55:36

您可以使用 DateTime.ParseExact-Methode (String, String, IFormatProvider, DateTimeStyles) 解析

此格式字符串为“yyyyMMddHHmmss.ffffffzzz”

You can parse this with DateTime.ParseExact-Methode (String, String, IFormatProvider, DateTimeStyles)

The format string is "yyyyMMddHHmmss.ffffffzzz"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文