TimeZoneInfo.DisplayName Property
Gets the localized general display name that represents the time zone.
Assembly: mscorlib (in mscorlib.dll)
Time zone display names for Windows system time zones follow a fairly standard format. The first portion of the display name is the time zone's base offset from Coordinated Universal Time, which is indicated by the acronym GMT (for Greenwich Mean Time), enclosed in parentheses. For Coordinated Universal Time, the GMT acronym with no offset is enclosed in parentheses. This is followed by a string that identifies the time zone or one or more of the cities, regions, or countries in the time zone. For example:
(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London (GMT+02:00) Athens, Beirut, Istanbul, Minsk (GMT-02:00) Mid-Atlantic (GMT-07:00) Mountain Time (US & Canada)
The following example retrieves a TimeZoneInfo object that represents the local time zone and outputs its display name, standard time name, and daylight saving time name.
TimeZoneInfo localZone = TimeZoneInfo.Local; Console.WriteLine("Local Time Zone ID: {0}", localZone.Id); Console.WriteLine(" Display Name is: {0}.", localZone.DisplayName); Console.WriteLine(" Standard name is: {0}.", localZone.StandardName); Console.WriteLine(" Daylight saving name is: {0}.", localZone.DaylightName);
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.
<#
.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
- 8/28/2010
- Thomas Lee