1 out of 18 rated this helpful - Rate this topic

TimeZoneInfo.Id Property

Gets the time zone identifier.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
public string Id { get; }

Property Value

Type: System.String
The time zone identifier.

The time zone identifier is a key string that uniquely identifies a particular time zone. In Windows XP and Windows Vista, it corresponds to the subkeys of the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Time Zone branch of the registry. It can be passed as a parameter to the FindSystemTimeZoneById method to retrieve a particular time zone from the registry.

Important note Important

If you are defining a custom time zone, you should not assign it an identifier longer than 32 characters because this is the maximum length supported by the Windows registry.

The value of the Id property is usually, but not always, identical to that of the StandardName property. The identifier of the Coordinated Universal Time zone is UTC.

The following example lists the identifier of each of the time zones defined on the local computer.


ReadOnlyCollection<TimeZoneInfo> zones = TimeZoneInfo.GetSystemTimeZones();
Console.WriteLine("The local system has the following {0} time zones", zones.Count);
foreach (TimeZoneInfo zone in zones)
   Console.WriteLine(zone.Id);


.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
TimeZoneInfo Id Sample Using PowerShell
<#
.SYNOPSIS
This script displays/Uses TimeZoneInfo properties
.DESCRIPTION
This script displays the use of all the TimeZoneInfo Properties.
.NOTES
File Name : Get-TimeZoneInfoInfo.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell Version 2.0
.LINK
This script posted to:
http://www.pshscripts.blogspot.com
MSDN Sample posted at:
http://msdn.microsoft.com/en-us/library/system.timezoneinfo_properties.aspx
.EXAMPLE
PSH [C:\foo]: .Get-TimeZoneInfoInfo.ps1'
Time Zone: (GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London
Time zone is 0 hours 0 minutes later than Coordinated Universal Time.
Current time is 12:22 PM on 8/28/2010 GMT Daylight Time
Timezone id : GMT Standard Time
Supports Daylight Saving : True
Daylight Saving Zone Name: GMT Daylight Time

Time Zone: (GMT+04:30) Kabul
Time zone is 4 hours 30 minutes later than Coordinated Universal Time.
Current time is 12:22 PM on 8/28/2010 Afghanistan Standard Time
Timezone id : Afghanistan Standard Time
Supports Daylight Saving : False
Daylight Saving Zone Name: Afghanistan Daylight Time

Time Zone: UTC
Time zone is 0 hours 0 minutes later than Coordinated Universal Time.
Current time is 12:22 PM on 8/28/2010 UTC
Timezone id : UTC
Supports Daylight Saving : False
Daylight Saving Zone Name: UTC
#>
# Display Information About Time Zones

# Get current date
$Datenow = Get-Date

# Display info re Local Time Zone
$LocalZone = [System.TimeZoneInfo]::Local
$t1 = [system.Math]::Abs($LocalZone.BaseUtcOffset.Hours)
$t2 = [System.Math]::Abs($LocalZone.BaseUtcOffset.Minutes)
$t3 = if ($LocalZone.BaseUtcOffset -ge [System.Timespan]::Zero) {"later"} else {"earlier"}
$t4 = if ($LocalZone.IsdaylightSavingTime($datenow)) {$Localzone.DaylightName} else {$Localzone.Standardname}
# Display information
"Time Zone: {0}" -f $Localzone.Displayname
" Time zone is {0} hours {1} minutes {2} than Coordinated Universal Time." -f $t1,$t2, $t3
" Current time is {0:t} on {0:d} {1}" -f $datenow,$t4
" Timezone id : {0}" -f $LocalZone.Id
" Supports Daylight Saving : {0}" -f $LocalZone.SupportsDaylightSavingTime
" Daylight Saving Zone Name: {0}" -f $Localzone.DaylightName
""

# Get Kabul Time
$Kt = [system.TimeZoneInfo]::GetSystemTimeZones() | ? {$_.id -match "Afghanistan Standard Time"}
$tz = $kt.Displayname
$t1 = [system.Math]::Abs($kt.BaseUtcOffset.Hours)
$t2 = [System.Math]::Abs($kt.BaseUtcOffset.Minutes)
$t3 = if ($kt.BaseUtcOffset -ge [System.timespan]::Zero) {"later"} else {"earlier"}
$t4 = if ($Kt.IsdaylightSavingTime($datenow)) {$Kt.DaylightName} else {$Kt.Standardname}

# Display information
"Time Zone: {0}" -f $Kt.Displayname
" Time zone is {0} hours {1} minutes {2} than Coordinated Universal Time." -f $t1,$t2,$t3
" Current time is {0:t} on {0:d} {1}" -f $datenow,$t4
" Timezone id : {0}" -f $Kt.Id
" Supports Daylight Saving : {0}" -f $Kt.SupportsDaylightSavingTime
" Daylight Saving Zone Name: {0}" -f $Kt.DaylightName
""

# Display Information regarding UTC
$UtcZone = [System.TimeZoneInfo]::UTC
$t1 = [system.Math]::Abs($UtcZone.BaseUtcOffset.Hours)
$t2 = [System.Math]::Abs($UtcZone.BaseUtcOffset.Minutes)
$t3 = if ($UtcZone.BaseUtcOffset -ge [System.Timespan]::Zero) {"later"} else {"earlier"}
$t4 = if ($UtcZone.IsdaylightSavingTime($datenow)) {$Utczone.DaylightName} else {$UtcZone.Standardname}

# Display information
"Time Zone: {0}" -f $UtcZone.Displayname
" Time zone is {0} hours {1} minutes {2} than Coordinated Universal Time." -f $t1,$t2,$t3
" Current time is {0:t} on {0:d} {1}" -f $Datenow,$t4
" Timezone id : {0}" -f $UtcZone.Id
" Supports Daylight Saving : {0}" -f $UtcZone.SupportsDaylightSavingTime
" Daylight Saving Zone Name: {0}" -f $UtcZone.DaylightName