How to Set Timezone Using PowerShell
A time zone refers to the system setting that reflects the current local time of the computer or device, as set by the user or default configurations. This setting is based on the relative offset from Coordinated Universal Time (UTC) or Greenwich Mean Time (GMT).
As a Windows user, you will encounter instances where you need to change the timezone of your Windows machine. In this tutorial, we will learn how to set the time zone on your machine using Windows PowerShell.
Windows Get Timezone
Let us start by getting the current timezone for your system. You can do this by running the following command:
Get-TimeZone
The command should return output as shown:
Id : E. Africa Standard Time
HasIanaId : False
DisplayName : (UTC+03:00) Nairobi
StandardName : E. Africa Standard Time
DaylightName : E. Africa Daylight Time
BaseUtcOffset : 03:00:00
SupportsDaylightSavingTime : False
To list all the available timezones, you can use the -ListAvailable
option as shown:
Get-TimeZone -ListAvailable
Example output:
Id : Dateline Standard Time
HasIanaId : False
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
HasIanaId : False
DisplayName : (UTC-11:00) Coordinated Universal Time-11
StandardName : UTC-11
DaylightName : UTC-11
BaseUtcOffset : -11:00:00
SupportsDaylightSavingTime : False
Id : Aleutian Standard Time
HasIanaId : False
DisplayName : (UTC-10:00) Aleutian Islands
StandardName : Aleutian Standard Time
DaylightName : Aleutian Daylight Time
BaseUtcOffset : -10:00:00
SupportsDaylightSavingTime : True
Id : Hawaiian Standard Time
HasIanaId : False
DisplayName : (UTC-10:00) Hawaii
StandardName : Hawaiian Standard Time
DaylightName : Hawaiian Daylight Time
BaseUtcOffset : -10:00:00
...
PowerShell Set Timezone By ID
To change the system timezone using PowerShell, you can use the Set-TimeZone
cmdlet followed by the target timezone name.
Example is as shown:
Set-TimeZone "Eastern Standard Time"
The command above should change the timezone to “Eastern Standard Time”. You can confirm by getting the timezone value:
Get-TimeZone
Output:
Id : Eastern Standard Time
HasIanaId : False
DisplayName : (UTC-05:00) Eastern Time (US & Canada)
StandardName : Eastern Standard Time
DaylightName : Eastern Daylight Time
BaseUtcOffset : -05:00:00
SupportsDaylightSavingTime : True
PowerShell Set Timezone By Name
We specified the target timezone using the Timezone ID in the example above. You can also set the Timezone by name, as shown:
Set-TimeZone -Name 'Coordinated Universal Time' -PassThru
This command should update the system timezone to the specified timezone.
PowerShell Get Timezone Using TZUTIL
Another method we can use to get and set the timezone of a Windows system is using the tzutil
.
tzutil
is a command-line utility on Windows that allows us to display or configure the current system’s time zone. The name “tzutil” is short for “Time Zone Utility”.
To get the current system timezone using this utility, use the /g
option as shown:
tzutil /g
Output:
UTC
To list all the available timezones in the system, use the /l
parameter as:
tzutil /l
Output:
(UTC-12:00) International Date Line West
Dateline Standard Time
(UTC-11:00) Coordinated Universal Time-11
UTC-11
(UTC-10:00) Aleutian Islands
Aleutian Standard Time
(UTC-10:00) Hawaii
Hawaiian Standard Time
(UTC-09:30) Marquesas Islands
Marquesas Standard Time
(UTC-09:00) Alaska
Alaskan Standard Time
---
PowerShell Set Timezone Using TZUTIL
To set a new timezone using the tzutil, you can run the command with the /s
parameter as shown:
tzutil /s "E. Africa Standard Time"
You can also use the /?
parameter to view the various command options.
Conclusion
In this post, we explored the various methods and techniques of getting and setting the system timezone in Windows using the PowerShell utilities.