Changing Current Time Zone

by Aug 13, 2013

In a previous tip you learned how PowerShell can list all available time zone IDs. Today, we show you how to set the time zone using the utility tzutil.exe.

First, here's a helper function that returns the correct time zone ID when you submit part of its name:

function Get-TimeZone($Name)
 [system.timezoneinfo]::GetSystemTimeZones() | 
 Where-Object { $_.ID -like "*$Name*" -or $_.DisplayName -like "*$Name*" } | 
 Select-Object -ExpandProperty ID

Here is how it works:

Once you know the official ID of the time zone, use tzutil.exe to make it your current time zone:

Note that if you specify an invalid time zone, you get both an error message, and $LASTEXITCODE will not be 0.

Note also that once you change the time zone, your clock in the taskbar will immediately change to that time zone.

Twitter This Tip! ReTweet this Tip!