Re: Time Error



More details:

1.
The LastBootUpTime value in Win32_OperatingSystem is also an hour off.

2.
The =Now() function in Excel displays the correct time.

3.
I also get the correct time when I run the Time command in a command
prompt DOS-style shell.

4.
To prove that all other settings are correct and that there is
definitely an illogical discrepancy in WMI, I came up with the script
code below, ran it, and copied the output further below.

SCRIPT:


=========================
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
WScript.Echo "Script executed: " & Now()
WScript.Echo

Set colItems = objWMIService.ExecQuery(_
"Select * From Win32_OperatingSystem")
For Each objItem in colItems
WScript.Echo "Win32_OperatingSystem:"
WScript.Echo "Caption = " & objItem.Caption
WScript.Echo "CSDVersion = " & objItem.CSDVersion
WScript.Echo "OSArchitecture = " & objItem.OSArchitecture
WScript.Echo "ServicePackMajorVersion = " & _
objItem.ServicePackMajorVersion
WScript.Echo "ServicePackMinorVersion = " & _
objItem.ServicePackMinorVersion
WScript.Echo "Version = " & objItem.Version

strLocalDateTime = objItem.LocalDateTime
WScript.Echo "CurrentTimeZone = " & _
objItem.CurrentTimeZone
WScript.Echo "LocalDateTime = " & objItem.LocalDateTime
strTime = Mid(strLocalDateTime, 9, 2) & ":" & _
Mid(strLocalDateTime, 11, 2) & ":" & _
Mid(strLocalDateTime, 13, 2)
strDate = Mid(strLocalDateTime, 5, 2) & "/" & _
Mid(strLocalDateTime, 7, 2) & "/" & _
Left(strLocalDateTime, 4)
strTZ = Right(strLocalDateTime, Len(strLocalDateTime)-21)
dtmDateTime = CDate(strDate & " " & strTime)
Wscript.Echo "LocalDateTime = " & dtmDateTime & _
" (GMT" & strTZ & ")"
Wscript.Echo "----------"
Next

Set colItems = objWMIService.ExecQuery(_
"Select * From Win32_LocalTime")
For Each objItem in colItems
strTime = objItem.Hour & ":" & objItem.Minute & ":" & _
objItem.Second
strDate = objItem.Month & "/" & objItem.Day & "/" & _
objItem.Year
dtmDateTime = CDate(strDate & " " & strTime)
WScript.Echo "Win32_LocalTime:"
Wscript.Echo "LocalTime = " & dtmDateTime
Wscript.Echo "----------"
Next

Set colItems = objWMIService.ExecQuery(_
"Select * From Win32_UTCTime")
For Each objItem in colItems
strTime = objItem.Hour & ":" & _
objItem.Minute & ":" & objItem.Second
strDate = objItem.Month & "/" & _
objItem.Day & "/" & objItem.Year
dtmDateTime = CDate(strDate & " " & strTime)
WScript.Echo "Win32_UTCTime:"
Wscript.Echo "UTCTime = " & dtmDateTime
Wscript.Echo "----------"
Next

Set colItems = objWMIService.ExecQuery(_
"Select * From Win32_ComputerSystem")
For Each objItem in colItems
WScript.Echo "Win32_ComputerSystem:"
WScript.Echo "CurrentTimeZone = " & _
objItem.CurrentTimeZone
WScript.Echo "DaylightInEffect = " & _
objItem.DaylightInEffect
WScript.Echo "EnableDaylightSavingsTime = " & _
objItem.EnableDaylightSavingsTime
Wscript.Echo "----------"
Next

Set colItems = objWMIService.ExecQuery(_
"Select * From Win32_TimeZone")
For Each objItem in colItems
WScript.Echo "Win32_TimeZone:"
WScript.Echo "Description = " & objItem.Description
WScript.Echo "Bias = " & objItem.Bias
WScript.Echo "DaylightBias = " & objItem.DaylightBias
WScript.Echo "Daylight Month/Day = " & _
objItem.DaylightMonth & "/" & objItem.DaylightDay
WScript.Echo "DaylightName = " & objItem.DaylightName
WScript.Echo "StandardBias = " & objItem.StandardBias
WScript.Echo "Standard Month/Day = " & _
objItem.StandardMonth & "/" & objItem.StandardDay
WScript.Echo "StandardName = " & objItem.StandardName
Next
=========================



OUTPUT:
=========================
Script executed: 11/5/2009 12:29:08 PM

Win32_OperatingSystem:
Caption = Microsoftr Windows VistaT Enterprise
CSDVersion = Service Pack 2
OSArchitecture = 32-bit
ServicePackMajorVersion = 2
ServicePackMinorVersion = 0
Version = 6.0.6002
CurrentTimeZone = -300
LocalDateTime = 20091105132908.265000-240
LocalDateTime = 11/5/2009 1:29:08 PM (GMT-240)
----------
Win32_LocalTime:
LocalTime = 11/5/2009 12:29:08 PM
----------
Win32_UTCTime:
UTCTime = 11/5/2009 5:29:08 PM
----------
Win32_ComputerSystem:
CurrentTimeZone = -300
DaylightInEffect = False
EnableDaylightSavingsTime = True
----------
Win32_TimeZone:
Description = (GMT-05:00) Eastern Time (US & Canada)
Bias = -300
DaylightBias = -60
Daylight Month/Day = 3/2
DaylightName = Eastern Daylight Time
StandardBias = 0
Standard Month/Day = 11/1
StandardName = Eastern Standard Time
=========================

Note that the time and offset/bias values for LocalDateTime do not
match ANY other values.

The LocalDateTime value, and anything that uses it, are simply WRONG.
(I haven't tested the script on WinXP, but the discrepancies are
the same in XP when viewed via CIM Studio.)

I would also point out that the old time change from EDT to EST was a
week EARLIER than it is now. So, nothing will be any different in mid-
November in our area (as Meanon indicated might be the case for his
area).

Is anyone else seeing this? I would love to hear back from Pegasus or
any other MVPs... or anyone for that matter.

Thanks.
.



Relevant Pages

  • Find Calendar Item from Location
    ... Public Function OutLookCode() ... Set colItems = objFolder.Items ... For Each objItem In colItems ... strTest = objItem.Subject ...
    (microsoft.public.outlook.program_vba)
  • Re: Send VBScript Output to an Excel Spreadsheet
    ... 'This script returns various computer information including computer ... If strComputers = "" Then ... For Each objItem in ColItems ... Set colItems = objWMIService.ExecQuery("SELECT * FROM ...
    (microsoft.public.scripting.vbscript)
  • Re: How to get System Resources info?
    ... Set colItems = objWMIService.ExecQuery ... For Each objItem in colItems ... > its realted device caption, ...
    (microsoft.public.windowsxp.wmi)
  • Re: Where is ootcimv2SecurityMicrosoftVolumeEncryption?
    ... Set colItems = objWMIService.ExecQuery("SELECT * FROM ... For Each objItem in colItems ... If objItem.DriveLetter = strSDL then ...
    (microsoft.public.scripting.vbscript)