Time zone setting allows us to set the time according to the geographical location the computer is located at. We can change the time zone of a computer in Date and Time properties window which can be opened by running timedate.cpl from Run window.
Few readers of the blog have put this question to me. Is it possible to set the time zone from command line?
The answer varies depending on which Windows edition you have. In Windows 7, we have a command called tzutil using which we can easily change time zone from windows command line. In Windows XP, it’s bit complicated.
You can run the below command to set timezone in Windows 7.
tzutil /s "Time zone Identifier"
Command to set time zone to Pacific Standard Time:
tzutil /s "Pacific Standard Time"
Command to set time zone to Central America standard time:
tzutil /s "Central America Standard Time"
Get the current time zone
We can find the current time zone by running the following command.
c:\>tzutil /g Pacific Standard Time c:\>
Get the list of time zones
Run the command ‘tzutil /l‘ to get the list of time zones available.
Windows XP/Server 2003
While searching for a solution to this problem I got to know that there is a Windows Resource kit tool called timezone.exe which can be used to change day light savings..It does not set time zone. I tried further to find if there is any registry hack and below is what I came up with.
I found that the below registry key stores the information about different time zones.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.
There is another registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation which has information about the current time zone. This registry has the following information on my computer.
Bias REG_DWORD 0x1e0
StandardName REG_SZ Pacific Standard Time
StandardBias REG_DWORD 0x0
StandardStart REG_BINARY 00000B00010002000000000000000000
DaylightName REG_SZ Pacific Daylight Time
DaylightBias REG_DWORD 0xffffffc4
DaylightStart REG_BINARY 00000300020002000000000000000000
ActiveTimeBias REG_DWORD 0x1e0
Now it’s clear that in order to change the time zone we need to put right data in these registry values.
Now the question is how to get these values for the time zone you want to set? It’s very simple. You just need to set the time to your desired time zone using GUI (timedate.cpl) and then capture the registry values by exporting the registry key TimeZoneInformation to a reg file. Whenever you want to set the time zone from command line just run the exported .reg file and then reboot the machine to make the changes effective. You can run the .reg command from a batch file also.
The above method works for all Windows versions – XP, Windows 7, Server 2003 and Server 2008.
There’s another method in circulation for setting time zone from command prompt.
RunDLL32.exe shell32.dll,Control_RunDLL timedate.cpl,,/Z Central Standard Time
When I had tested the command on XP, I found that it does not work for all the timezones. In Windows 7, it does not work at all. It just opens the time and date configuration window.