Win32_TimeZone class

The Win32_TimeZoneWMI class represents the time zone information for a computer system running Windows, which includes the changes required for transitioning to daylight saving time transition.

The following syntax is simplified from Managed Object Format (MOF) code and includes all of the inherited properties. Properties and methods are in alphabetic order, not MOF order.

Syntax

[Dynamic, Provider("CIMWin32"), UUID("{8502C4EC-5FBB-11D2-AAC1-006008C78BC7}"), AMENDMENT]
class Win32_TimeZone : CIM_Setting
{
  string Caption;
  string Description;
  string SettingID;
  sint32 Bias;
  sint32 DaylightBias;
  uint32 DaylightDay;
  uint8  DaylightDayOfWeek;
  uint32 DaylightHour;
  uint32 DaylightMillisecond;
  uint32 DaylightMinute;
  uint32 DaylightMonth;
  string DaylightName;
  uint32 DaylightSecond;
  uint32 DaylightYear;
  uint32 StandardBias;
  uint32 StandardDay;
  uint8  StandardDayOfWeek;
  uint32 StandardHour;
  uint32 StandardMillisecond;
  uint32 StandardMinute;
  uint32 StandardMonth;
  string StandardName;
  uint32 StandardSecond;
  uint32 StandardYear;
};

Members

The Win32_TimeZone class has these types of members:

Properties

The Win32_TimeZone class has these properties.

Bias

Data type: sint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|Bias"), Units ("minutes")

Current bias for local time translation. The bias is the difference between Coordinated Universal Time (UTC) and local time. All translations between UTC and local time are based on the following formula: UTC = local time - bias. This property is required.

Caption

Data type: string

Access type: Read-only

Qualifiers: MaxLen (64)

Short textual description of the current object.

This property is inherited from CIM_Setting.

DaylightBias

Data type: sint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightBias"), Units ("minutes")

Bias value to be used during local time translations that occur during daylight saving time. This property is ignored if a value for the DaylightDay property is not supplied. The value of this property is added to the Bias property to form the bias used during daylight time. In most time zones, the value of this property is -60.

DaylightDay

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightDate|wDay")

DaylightDayOfWeek of the DaylightMonth when the transition from standard time to daylight saving time occurs on this operating system.

Example: If the transition day (DaylightDayOfWeek) occurs on a Sunday, then the value "1" indicates the first Sunday of the DaylightMonth, "2" indicates the second Sunday, and so on. The value "5" indicates the last DaylightDayOfWeek in the month.

DaylightDayOfWeek

Data type: uint8

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightDate|wDayOfWeek")

Day of the week when the transition from standard time to daylight saving time occurs on an operating system.

Sunday (0)

Monday (1)

Tuesday (2)

Wednesday (3)

Thursday (4)

Friday (5)

Saturday (6)

Example: 1

DaylightHour

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightDate|wHour")

Hour of the day when the transition from standard time to daylight saving time occurs on an operating system.

Example: 2

DaylightMillisecond

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightDate|wMilliseconds")

Millisecond of the DaylightSecond when the transition from standard time to daylight saving time occurs on an operating system.

DaylightMinute

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightDate|wMinute")

Minute of the DaylightHour when the transition from standard time to daylight saving time occurs on an operating system.

Example: 59

DaylightMonth

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightDate|wMonth")

Month when the transition from standard time to daylight saving time occurs on an operating system.

January (1)

February (2)

March (3)

April (4)

May (5)

June (6)

July (7)

August (8)

September (9)

October (10)

November (11)

December (12)

DaylightName

Data type: string

Access type: Read-only

Qualifiers: MaxLen (256), MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightName")

Time zone being represented when daylight saving time is in effect.

Example: "EDT" (Eastern Daylight Time)

DaylightSecond

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightDate|wSecond")

Second of the DaylightMinute when the transition from standard time to daylight saving time occurs on an operating system.

Example: 59

DaylightYear

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|DaylightDate|wYear")

Year when daylight saving time is in effect. This property is not required.

Example: 1997

Description

Data type: string

Access type: Read-only

Textual description of the current object.

This property is inherited from CIM_Setting.

SettingID

Data type: string

Access type: Read-only

Qualifiers: MaxLen (256)

Identifier by which the current object is known.

This property is inherited from CIM_Setting.

StandardBias

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardBias"), Units ("minutes")

Bias value to use when daylight saving time is not in effect. This property is ignored if a value for StandardDay is not supplied. The value of this property is added to the Bias property to form the bias during standard time.

Example: 0

StandardDay

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardDate|wDay")

StandardDayOfWeek of the StandardMonth when the transition from daylight saving time to standard time occurs on an operating system.

If the transition day (StandardDayOfWeek) occurs on a Sunday, then the value "1" indicates the first Sunday of the StandardMonth, "2" indicates the second Sunday, and so on. The value "5" indicates the last StandardDayOfWeek in the month.

StandardDayOfWeek

Data type: uint8

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardDate|wDayOfWeek")

Day of the week when the transition from daylight saving time to standard time occurs on an operating system.

Sunday (0)

Monday (1)

Tuesday (2)

Wednesday (3)

Thursday (4)

Friday (5)

Saturday (6)

StandardHour

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardDate|wHour")

Hour of the day when the transition from daylight saving time to standard time occurs on an operating system.

Example: 11

StandardMillisecond

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardDate|wMilliseconds")

Millisecond of the StandardSecond when the transition from daylight saving time to standard time occurs on an operating system.

StandardMinute

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardDate|wMinute")

Minute of the StandardDay when the transition from daylight saving time to standard time occurs on an operating system.

Example: 59

StandardMonth

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardDate|wMonth")

Month when the transition from daylight saving time to standard time occurs on an operating system.

January (1)

February (2)

March (3)

April (4)

May (5)

June (6)

July (7)

August (8)

September (9)

October (10)

November (11)

December (12)

StandardName

Data type: string

Access type: Read-only

Qualifiers: key, MaxLen (256), MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardName")

Name of the time zone being represented when standard time is in effect.

Example: "EST" (Eastern Standard Time)

StandardSecond

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardDate|wSecond")

Second of the StandardMinute when the transition from daylight saving time to standard time occurs on an operating system.

Example: 59

StandardYear

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Time Structures|TIME_ZONE_INFORMATION|StandardDate|wYear")

Year when standard time is in effect. This property is not required.

Example: 1997

Remarks

The Win32_TimeZone class is derived from CIM_Setting.

You cannot use standard date-time formats - such as 10/18/2002 - when writing WMI queries. Instead, you need to convert any dates used in your queries to UTC format. This requires two steps: 1) You must determine the offset (difference in minutes) between your time zone and Greenwich Mean Time, and 2) you must convert 10/18/2002 to a UTC value.

Determining the Offset from Greenwich Mean Time

Admittedly, WMI makes it difficult to work with dates and times; fortunately, WMI at least makes it easy to determine the offset between your time zone and Greenwich Mean Time. The WMI class Win32_TimeZone includes a property - Bias - that returns the GMT offset.

strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colTimeZone = objSWbemServices.ExecQuery _
 ("SELECT * FROM Win32_TimeZone")
For Each objTimeZone in colTimeZone
 Wscript.Echo "Offset: "& objTimeZone.Bias
Next

Converting a Date to a UTC Value

After you determine the GMT offset, you must then convert a standard date such as 10/18/2002 to a UTC date. To convert a standard date to a UTC date, you can use VBScript date functions such as Year, Month, and Day to isolate the individual components that make up a UTC date. After you have individual values for these components, you can concatenate them in the same manner as you would any other string value. UTC dates are treated as strings because the GMT offset must be appended to the end. If the date were seen as a number, this value:

20011018113047.000000-480

Would be erroneously treated as a mathematical equation (parentheses added for clarity):

(20011018113047.000000) - (480)

For example, in the date 10/18/2002, the individual components are:

  • Year: 2002
  • Month: 10
  • Day: 18

The script would need to combine these three values, the string "113047.000000" (representing the time, including milliseconds), and the GMT offset to derive a UTC date. For example, (parentheses again added for clarity):

(2002) & (10) & (18) & (113047.000000) & (-480)

Note

You can use the VBScript functions Hour, Minute, and Second to convert the time portion of a UTC date. Thus, a time such as 11:30:47 A.M. would be converted to 113047.

 

There is one complicating factor. The month must take up positions 5 and 6 in the string; the day must take up positions 7 and 8. This is no problem with month 10 and day 18. But how do you get July 5 (month 7, day 5) to fill up the requisite positions? The answer is to add a leading zero to each value, thus changing the 7 to 07 and the 5 to 05.

To do this, use the VBScript Len function to check the length (number of characters) in the month and the day. If the length is 1 (meaning that there is just one character), add a leading zero. Thus:

If Len(dtmMonth) = 1 Then
    dtmMonth = "0" & dtmMonth
End If

Examples

The following VBScript example converts the current date to a UTC date.

strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colTimeZone = objSWbemServices.ExecQuery _
 ("SELECT * FROM Win32_TimeZone")
For Each objTimeZone in colTimeZone
 strBias = objTimeZone.Bias
Next

dtmCurrentDate = Date
dtmTargetDate = Year(dtmCurrentDate)

dtmMonth = Month(dtmCurrentDate)
If Len(dtmMonth) = 1 Then
 dtmMonth = "0" & dtmMonth
End If

dtmTargetDate = dtmTargetDate & dtmMonth

dtmDay = Day(dtmCurrentDate)
If Len(dtmDay) = 1 Then
 dtmDay = "0" & dtmDay
End If

dtmTargetDate = dtmTargetDate & dtmDay & "000000.000000"
dtmTargetDate = dtmTargetDate & Cstr(strBias)

The following VBScript sampledetermines the GMT offset, and then converts a specified current date (in this case, 10/18/2002) to UTC date-time format. After the date has been converted, that value is used to search a computer and returns a list of all the folders that were created after 10/18/2002.

strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colTimeZone = objSWbemServices.ExecQuery _
 ("SELECT * FROM Win32_TimeZone")
For Each objTimeZone in colTimeZone
 strBias = objTimeZone.Bias
Next

dtmCurrentDate = "10/18/2002"
dtmTargetDate = Year(dtmCurrentDate)

dtmMonth = Month(dtmCurrentDate)
If Len(dtmMonth) = 1 Then
 dtmMonth = "0" & dtmMonth
End If

dtmTargetDate = dtmTargetDate & dtmMonth

dtmDay = Day(dtmCurrentDate)
If Len(dtmDay) = 1 Then
 dtmDay = "0" & dtmDay
End If

dtmTargetDate = dtmTargetDate & dtmDay & "000000.000000"
dtmTargetDate = dtmTargetDate & Cstr(strBias)

Set colFolders = objSWbemServices.ExecQuery _
 ("SELECT * FROM Win32_Directory WHERE CreationDate < '" & _
 dtmtargetDate & "'")
For Each objFolder in colFolders
 Wscript.Echo objFolder.Name
Next

The following VBScript code example displays the settings for Win32_TimeZone instances.

Dim arDayOrWeek(7)
arDayOrWeek(0) = "Sunday"
arDayOrWeek(1) = "Monday"
arDayOrWeek(2) = "Tuesday"
arDayOrWeek(3) = "Wednesday"
arDayOrWeek(4) = "Thursday"
arDayOrWeek(5) = "Friday"
arDayOrWeek(6) = "Saturday"

Dim arMonth(13)
arMonth(1) = "January"
arMonth(2) = "Feburary"
arMonth(3) = "March"
arMonth(4) = "April"
arMonth(5) = "May"
arMonth(6) = "June"
arMonth(7) = "July"
arMonth(8) = "August"
arMonth(9) = "September"
arMonth(10) = "October"
arMonth(11) = "November"
arMonth(12) = "December"

strComputer = "."
wmiQuery = "Select * from Win32_TimeZone"
Set objWMIService = GetObject("winmgmts:\\" & _
    strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery(wmiQuery)

For Each objItem in colItems
    WScript.Echo "Day of Week setting is: " _
        & objItem.dayLightDayOfWeek _
        & " which is: " & arDayOrWeek(objItem.DaylightDayOfWeek)
    WScript.Echo "Hour: " & objItem.DaylightHour 
    WScript.Echo "Month: " & objItem.DaylightMonth _
        & " which is: " & arMonth(objItem.DaylightMonth )
    WScript.Echo "Description: " & objItem.DaylightName 
    WScript.Echo "The transition from DLS to Standard occurs: " 
    WScript.Echo "Day of Week setting is: " _
        & objItem.standardDayOfWeek _
        & " which is: " & arDayOrWeek(objItem.DaylightDayOfWeek)
    WScript.Echo "Hour: " & objItem.StandardHour 
    WScript.Echo "Month: " & objItem.StandardMonth _ 
        & " which is: " & arMonth(objItem.StandardMonth )
    WScript.Echo "Description: " & objItem.StandardName 
Next

Requirements

Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Namespace
Root\CIMV2
MOF
CIMWin32.mof
DLL
CIMWin32.dll

See also

CIM_Setting

Operating System Classes

SWbemDateTime

Date and Time Format

WMI Tasks: Dates and Times