Getting Timezones

by Mar 26, 2012

Here's a low level call that returns all time zones:

PS> [System.TimeZoneInfo]::GetSystemTimeZones()

Id                         : Dateline Standard Time
DisplayName                : (UTC-12:00) International Date Line West
StandardName               : Dateline Standard Time
DaylightName               : Dateline Daylight Time
BaseUtcOffset              : -12:00:00
SupportsDaylightSavingTime : False

Id                         : UTC-11
DisplayName                : (UTC-11:00) Coordinated Universal Time-11
StandardName               : UTC-11
DaylightName               : UTC-11
BaseUtcOffset              : -11:00:00
SupportsDaylightSavingTime : False

To find the time zone you are in, use this:

PS> [System.TimeZoneInfo]::Local

Id                         : W. Europe Standard Time
DisplayName                : (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
StandardName               : W. Europe Standard Time
DaylightName               : W. Europe Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

PS> ([System.TimeZoneInfo]::Local).StandardName
W. Europe Standard Time

Twitter This Tip! ReTweet this Tip!