本文介绍了转换WMI的Win32_OperatingSystem InstallDate以MM / DD / yyyy格式(C# - WPF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道你将如何转换的日期和时间20100131022308.000000-360。
I am wondering how you would convert the date and time from 20100131022308.000000-360.
我一直在试图弄明白了一段时间,现在我似乎无法取得任何进展。
I've been trying to figure it out for a while now and I can't seem to get anywhere.
我正在使用WPF应用程序C#。
I am using C# in a WPF Application.
推荐答案
该System.Management.ManagementDateTimeConverter类是为了解决你的问题。使用它的ToDateTime()方法。它正确分析毫秒,UTC在字符串中的偏移量:
The System.Management.ManagementDateTimeConverter class was made to solve your problem. Use its ToDateTime() method. It properly parses milliseconds and the UTC offset in the string:
DateTime dt = System.Management.ManagementDateTimeConverter.ToDateTime("20100131022308.000000-360");
Console.WriteLine(dt);
输出:2010/1/31上午二时23分08秒
Output:1/31/2010 2:23:08 AM
这篇关于转换WMI的Win32_OperatingSystem InstallDate以MM / DD / yyyy格式(C# - WPF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!