#PSTip Enumerate Time Zones that support day light savings

I was recently working on WPF based UI for one of my PowerShell modules and in the process, I had to figure out a way to find out if a selected timezone supports day light savings or not. I’d initially looked at System.TimeZone .NET class but could not find any relevant method or property.

The GetSystemTimeZones() method in System.TimeZoneInfo class was what I really needed. This method returns a set of time zones available on the local system and this includes a property called SupportsDayLightSavingTime property. We can use this property to filter out what we need!

[System.TimeZoneInfo]::GetSystemTimeZones() | Where { $_.SupportsDayLightSavingTime }

About the author: Ravikanth C

Ravikanth is the founder and editor of the PowerShell Magazine. He is also a PowerShell MVP who works at Dell Inc. He blogs at http://www.ravichaganti.com/blog and you can follow him on Twitter @ravikanth.

Related Posts

%d bloggers like this: