Win32_TimeZone

Win32 Time Zone
root/cimv2dynamickey : StandardName

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

On this page

Main example

List instances

# All instances of Win32_TimeZone, with the main properties
Get-CimInstance -ClassName Win32_TimeZone |
    Select-Object -Property StandardName, Caption, Description, Bias

Examples

Filter with WQL

# WQL filter evaluated by the provider: DaylightDayOfWeek = 0 (Sunday)
Get-CimInstance -ClassName Win32_TimeZone -Filter 'DaylightDayOfWeek = 0' |
    Select-Object -Property StandardName, Caption, Description, Bias

The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.

Decode numeric values

# Lookup table for DaylightDayOfWeek (values documented by Microsoft)
$daylightDayOfWeekName = @{
    0 = 'Sunday'
    1 = 'Monday'
    2 = 'Tuesday'
    3 = 'Wednesday'
    4 = 'Thursday'
    5 = 'Friday'
    6 = 'Saturday'
}
# Lookup table for DaylightMonth (values documented by Microsoft)
$daylightMonthName = @{
    1 = 'January'
    2 = 'February'
    3 = 'March'
    4 = 'April'
    5 = 'May'
    6 = 'June'
    7 = 'July'
    8 = 'August'
    9 = 'September'
    10 = 'October'
    11 = 'November'
    12 = 'December'
}

Get-CimInstance -ClassName Win32_TimeZone |
    Select-Object -Property @(
        'StandardName'
        'Caption'
        'Description'
        'Bias'
        @{ Name = 'DaylightDayOfWeek'; Expression = { $daylightDayOfWeekName[[int]$_.DaylightDayOfWeek] } }
        @{ Name = 'DaylightMonth'; Expression = { $daylightMonthName[[int]$_.DaylightMonth] } }
    )

Query a remote computer (CIM session)

review before running
# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
    Get-CimInstance -CimSession $cimSession -ClassName Win32_TimeZone |
        Select-Object -Property StandardName, Caption, Description, Bias
} finally {
    Remove-CimSession -CimSession $cimSession
}

WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.

Show the class structure

# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_TimeZone
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

Properties

24 of 24 properties
NameTypeAccessDescription
Biassint32read

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.

Unit: minutes

Code
# Value of Bias for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, Bias |
    Select-Object -Property StandardName, Bias
Captionstringread

Short textual description of the current object.

Code
# Value of Caption for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, Caption |
    Select-Object -Property StandardName, Caption
DaylightBiassint32read

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.

Unit: minutes

Code
# Value of DaylightBias for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightBias |
    Select-Object -Property StandardName, DaylightBias
DaylightDayuint32read

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.

Code
# Value of DaylightDay for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightDay |
    Select-Object -Property StandardName, DaylightDay
DaylightDayOfWeekuint8read

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

Example: 1

Values (7)
ValueLabelDescription
0Sunday
1Monday
2Tuesday
3Wednesday
4Thursday
5Friday
6Saturday
Code
# Value of DaylightDayOfWeek for each instance
# Lookup table for DaylightDayOfWeek (values documented by Microsoft)
$daylightDayOfWeekName = @{
    0 = 'Sunday'
    1 = 'Monday'
    2 = 'Tuesday'
    3 = 'Wednesday'
    4 = 'Thursday'
    5 = 'Friday'
    6 = 'Saturday'
}
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightDayOfWeek |
    Select-Object -Property @(
        'StandardName'
        @{ Name = 'DaylightDayOfWeek'; Expression = { $daylightDayOfWeekName[[int]$_.DaylightDayOfWeek] } }
    )
DaylightHouruint32read

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

Example: 2

Code
# Value of DaylightHour for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightHour |
    Select-Object -Property StandardName, DaylightHour
DaylightMilliseconduint32read

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

Code
# Value of DaylightMillisecond for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightMillisecond |
    Select-Object -Property StandardName, DaylightMillisecond
DaylightMinuteuint32read

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

Example: 59

Code
# Value of DaylightMinute for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightMinute |
    Select-Object -Property StandardName, DaylightMinute
DaylightMonthuint32read

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

Values (12)
ValueLabelDescription
1January
2February
3March
4April
5May
6June
7July
8August
9September
10October
11November
12December
Code
# Value of DaylightMonth for each instance
# Lookup table for DaylightMonth (values documented by Microsoft)
$daylightMonthName = @{
    1 = 'January'
    2 = 'February'
    3 = 'March'
    4 = 'April'
    5 = 'May'
    6 = 'June'
    7 = 'July'
    8 = 'August'
    9 = 'September'
    10 = 'October'
    11 = 'November'
    12 = 'December'
}
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightMonth |
    Select-Object -Property @(
        'StandardName'
        @{ Name = 'DaylightMonth'; Expression = { $daylightMonthName[[int]$_.DaylightMonth] } }
    )
DaylightNamestringread

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

Example: "EDT" (Eastern Daylight Time)

Code
# Value of DaylightName for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightName |
    Select-Object -Property StandardName, DaylightName
DaylightSeconduint32read

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

Example: 59

Code
# Value of DaylightSecond for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightSecond |
    Select-Object -Property StandardName, DaylightSecond
DaylightYearuint32read

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

Example: 1997

Code
# Value of DaylightYear for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, DaylightYear |
    Select-Object -Property StandardName, DaylightYear
Descriptionstringread

Textual description of the current object.

Code
# Value of Description for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, Description |
    Select-Object -Property StandardName, Description
SettingIDstringread

Identifier by which the current object is known.

Code
# Value of SettingID for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, SettingID |
    Select-Object -Property StandardName, SettingID
StandardBiasuint32read

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

Unit: minutes

Code
# Value of StandardBias for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardBias |
    Select-Object -Property StandardName, StandardBias
StandardDayuint32read

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.

Code
# Value of StandardDay for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardDay |
    Select-Object -Property StandardName, StandardDay
StandardDayOfWeekuint8read

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

Values (7)
ValueLabelDescription
0Sunday
1Monday
2Tuesday
3Wednesday
4Thursday
5Friday
6Saturday
Code
# Value of StandardDayOfWeek for each instance
# Lookup table for StandardDayOfWeek (values documented by Microsoft)
$standardDayOfWeekName = @{
    0 = 'Sunday'
    1 = 'Monday'
    2 = 'Tuesday'
    3 = 'Wednesday'
    4 = 'Thursday'
    5 = 'Friday'
    6 = 'Saturday'
}
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardDayOfWeek |
    Select-Object -Property @(
        'StandardName'
        @{ Name = 'StandardDayOfWeek'; Expression = { $standardDayOfWeekName[[int]$_.StandardDayOfWeek] } }
    )
StandardHouruint32read

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

Example: 11

Code
# Value of StandardHour for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardHour |
    Select-Object -Property StandardName, StandardHour
StandardMilliseconduint32read

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

Code
# Value of StandardMillisecond for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardMillisecond |
    Select-Object -Property StandardName, StandardMillisecond
StandardMinuteuint32read

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

Example: 59

Code
# Value of StandardMinute for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardMinute |
    Select-Object -Property StandardName, StandardMinute
StandardMonthuint32read

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

Values (12)
ValueLabelDescription
1January
2February
3March
4April
5May
6June
7July
8August
9September
10October
11November
12December
Code
# Value of StandardMonth for each instance
# Lookup table for StandardMonth (values documented by Microsoft)
$standardMonthName = @{
    1 = 'January'
    2 = 'February'
    3 = 'March'
    4 = 'April'
    5 = 'May'
    6 = 'June'
    7 = 'July'
    8 = 'August'
    9 = 'September'
    10 = 'October'
    11 = 'November'
    12 = 'December'
}
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardMonth |
    Select-Object -Property @(
        'StandardName'
        @{ Name = 'StandardMonth'; Expression = { $standardMonthName[[int]$_.StandardMonth] } }
    )
StandardName keystringread

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

Example: "EST" (Eastern Standard Time)

Code
# Value of StandardName for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName |
    Select-Object -Property StandardName
StandardSeconduint32read

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

Example: 59

Code
# Value of StandardSecond for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardSecond |
    Select-Object -Property StandardName, StandardSecond
StandardYearuint32read

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

Example: 1997

Code
# Value of StandardYear for each instance
Get-CimInstance -ClassName Win32_TimeZone -Property StandardName, StandardYear |
    Select-Object -Property StandardName, StandardYear

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.

```VB

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:

```VB

If Len(dtmMonth) = 1 Then

dtmMonth = "0" & dtmMonth

End If

```

Inheritance

Superclass chain

  1. CIM_Setting
  2. Win32_TimeZone

Known subclasses

No known subclass.

Requirements

Namespace
root/cimv2
Minimum client
Windows Vista
Minimum server
Windows Server 2008
Provider
CIMWin32
MOF file
CIMWin32.mof
DLL
CIMWin32.dll
Class qualifiers

Dynamic Provider("CIMWin32") UUID("{8502C4EC-5FBB-11D2-AAC1-006008C78BC7}") AMENDMENT

Microsoft source

Source: Microsoft Learn

Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.