locked
TimeWritten give back a UTC date??? RRS feed

  • Question

  • Hello,

    i use a JS function to get the info from system logfile (Win32_NTLogEvent), i need the date for the logfile, so i use the property TimeWritten. But it always give me a UTC time.

    my code:

    var intNumberID = 6006;
    var wmiService = GetObject("winmgmts:\\\\.\\root\\CIMV2");

    var SYSTEM_LOG_QUERY ="Select * from Win32_NTLogEvent Where Logfile = 'System'" ;

    function Downtime()

       var colLoggedEvents = wmiService.ExecQuery(SYSTEM_LOG_QUERY);
       var intEvent = new Enumerator(colLoggedEvents);
       for(;!intEvent.atEnd();intEvent.moveNext())
       {
       if(intEvent.item().EventCode == intNumberID)
       {
          var s= intEvent.item();
       break;
       }
       }
       var rawLastShutDownTime = s.TimeWritten;
       var year = rawLastShutDownTime.substr(0, 4);
     var month = rawLastShutDownTime.substr(4, 2);
     var day = rawLastShutDownTime.substr(6, 2);
     var hour = rawLastShutDownTime.substr(8, 2);
     var minute = rawLastShutDownTime.substr(10, 2);
     var second = rawLastShutDownTime.substr(12, 2);
     var lastShutDownTime = new Date (year, month-1, day, hour, minute, second);
      }

    As result become ich the lastdowntime such as: Sun Jul 24 15:00:00 UTC+0200 2011

    and in my eventviewer i see the time 17:00:00

     

    How can i get a local time?

     

    Thanks in advance.

    Sunday, July 24, 2011 4:25 PM