Powershell get timezone with DST

In powershell I’m using


to get the UTC offset of a computer which gives me +1h for my timezone. That is technically correct since I’m in CET in winter (UTC+1) and CEST in summer (UTC+2). Right now tho it is DST, so CEST (UTC+2) for me so I’m wondering how I could get this information in powershell since the above command tells me that my timezone is UTC+1 and doesn’t mention DST at all.

As a workaround I currently use

$date = Get-Date
($date - $date.ToUniversalTime()).TotalMinutes

to get the offset from UTC of my timezone with DST. It evaluates to +120 minutes which is exactly what i need.

Output of Get-Timezone:

Id                         : W. Europe Standard Time
DisplayName                : (UTC+01:00) Amsterdam, Berlin, Bern, Rom, Stockholm, Wien
StandardName               : Mitteleuropäische Zeit
DaylightName               : Mitteleuropäische Sommerzeit
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

Output of $date – $date.ToUniversalTime():

Days              : 0
Hours             : 2
Minutes           : 0
Seconds           : 0
Milliseconds      : 0
Ticks             : 72000000000
TotalDays         : 0,0833333333333333
TotalHours        : 2
TotalMinutes      : 120
TotalSeconds      : 7200
TotalMilliseconds : 7200000

>Solution :

Yes, you can use the static method IsDaylightSavingTime on the TimeZoneInfo class to get this information from a desired DateTime:

$now = [DateTime]::Now
[System.TimeZoneInfo]::Local.IsDaylightSavingTime($now) # Returns $True or $False

Leave a Reply