Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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

[Provider("CIMWin32")]class Win32_TimeZone : CIM_Setting
{
  sint32 Bias;
  string Caption;
  sint32 DaylightBias;
  uint32 DaylightDay;
  uint8  DaylightDayOfWeek;
  uint32 DaylightHour;
  uint32 DaylightMillisecond;
  uint32 DaylightMinute;
  uint32 DaylightMonth;
  string DaylightName;
  uint32 DaylightSecond;
  uint32 DaylightYear;
  string Description;
  string SettingID;
  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: 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

Short description of the CIM_Setting object—a one-line string.

DaylightBias
Data type: sint32
Access type: Read-only
Qualifiers: 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

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

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

ValueMeaning
0 (0x0)

Sunday

1 (0x1)

Monday

2 (0x2)

Tuesday

3 (0x3)

Wednesday

4 (0x4)

Thursday

5 (0x5)

Friday

6 (0x6)

Saturday

 

Example: 1

DaylightHour
Data type: uint32
Access type: Read-only

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

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

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

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

ValueMeaning
1 (0x1)

January

2 (0x2)

February

3 (0x3)

March

4 (0x4)

April

5 (0x5)

May

6 (0x6)

June

7 (0x7)

July

8 (0x8)

August

9 (0x9)

September

10 (0xA)

October

11 (0xB)

November

12 (0xC)

December

 

DaylightName
Data type: string
Access type: Read-only
Qualifiers: MaxLen (256)

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

Example: "EDT" (Eastern Daylight Time)

DaylightSecond
Data type: uint32
Access type: Read-only

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

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

Example: 1997

Description
Data type: string
Access type: Read-only

Description of the CIM_Setting object.

SettingID
Data type: string
Access type: Read-only

Identifier for the CIM_Setting object.

StandardBias
Data type: uint32
Access type: Read-only
Qualifiers: 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

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

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

ValueMeaning
0 (0x0)

Sunday

1 (0x1)

Monday

2 (0x2)

Tuesday

3 (0x3)

Wednesday

4 (0x4)

Thursday

5 (0x5)

Friday

6 (0x6)

Saturday

 

StandardHour
Data type: uint32
Access type: Read-only

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

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

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

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

ValueMeaning
1 (0x1)

January

2 (0x2)

February

3 (0x3)

March

4 (0x4)

April

5 (0x5)

May

6 (0x6)

June

7 (0x7)

July

8 (0x8)

August

9 (0x9)

September

10 (0xA)

October

11 (0xB)

November

12 (0xC)

December

 

StandardName
Data type: string
Access type: Read-only
Qualifiers: Key, MaxLen (256)

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

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

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 2003

Namespace

\root\CIMV2

MOF

CIMWin32.mof

DLL

CIMWin32.dll

See also

Operating System Classes
SWbemDateTime
Date and Time Format
WMI Tasks: Dates and Times

 

 

Show:
© 2014 Microsoft