WMI Time Zone Information

Using WMI we can also examine time zone information that is set locally on an individual computer.

First we'll need access to the WMI namespace, in this case the function is as follows.

Function GetWMI() As Object

Dim strComputer As String

  strComputer = "."
  Set GetWMI = GetObject( _
               "winmgmts:\\" & strComputer & "\root\cimv2")

End Function

Then to get the local time zone information, run the following procedure.

Specifically, it returns the name of the current time zone, as well as the name of daylight savings and standard times.

Sub TestGetWMIDateAndTime()

Dim objWMI As Object
Dim colItems As Object
Dim objItem As Object

  Set objWMI = GetWMI

  Set colItems = objWMI.ExecQuery( _
                 "Select * from Win32_TimeZone")
  For Each objItem In colItems
    Debug.Print "Description: " & objItem.Description
    Debug.Print "Daylight Name: " & objItem.DaylightName
    Debug.Print "Standard Name: " & objItem.StandardName
  Next objItem

End Sub

I ran it on my computer and this was the output:

Description: (GMT-05:00) Eastern Time (US & Canada)
Daylight Name: Eastern Daylight Time
Standard Name: Eastern Standard Time

Site last updated: May 17, 2012

Random Data Generator