Search code examples
winapimfcshutdown

How to Get the correct shutdown time of the Windows system Using Win32 or MFC


I am trying to get the last shutdown time of the system. I tried event log EvtQuery() method and got the value Event/System/TimeCreated/@SystemTime but it is not accurate.

I need this Time and date value: SystemTime

I got value only from here, dates are the same but time is different: SystemTime


Solution

  • Your timestamps do match, but one is in UTC (17:21:34) the other in local time (10:51:34 PM -> 22:51:34).

    So it looks like your local timezone is 5:30 ahead of UTC time. So according to wikipedia that would be parts of India or Sri Lanka.

    So what you have to do is convert the local time value to UTC (or the other way around) and you should see that they are the same.

    There should be plenty of material for this on StackOverflow (try this search for example).