user1438082 user1438082 - 1 year ago 104
C# Question

Date Time Format of 20131205205012.000000-000

When i query using WMI the event log the time an event occurred is 20131205205012.000000-000 for example

how can i convert this to yymmdd hh:mm:ss or similar
Out of interest what format is this ?

C# Code

this.radGridViewEvents.Columns.Add("Time Written");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_NTLogEvent WHERE EventType = 1");
foreach (ManagementObject queryObj in searcher.Get())

Answer Source

Its UTC format, similar to this but without the seperators/punctuation;


I am unsure what the -000 represents, but I assume the rest are the second fractions. One way to parse it is to use DateTime.ParseExact. Assuming you trim off the -000, you can parse the rest like so;

var date = DateTime.ParseExact("20131205205012.000000", 
                                           DateTimeStyles.AssumeUniversal |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download