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.
Windows 7:
You can run the below command to set timezone in Windows 7.
tzutil /s "Time zone Identifier"
Examples:
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"
Windows XP/Server 2003:
While searching for a solution to this problem I have 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 have tried further to find if there is any registry hack and below is what I have come up with.
I have 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.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
Bias REG_DWORD 0x1e0
StandardName REG_SZ Pacific Standard Time
StandardBias REG_DWORD 0×0
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 have tested the command on XP, I have 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.
{ 6 comments… read them below or add one }
CONTROL.EXE TIMEDATE.CPL,,/Z W. Europe Standard Time
y tests showed that this does not work if you use the names that are shown in the XP timezone dialog. It seems that those are only display names.
When I used the names for the subkey of
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
it worked well. Those names are all English and it seems that XP needs that.
Hi,
Your solution of changing time zone works very nicely. But to reflect changes made in registry we have to restart the machine. Is there anyway to immediately reflect updated timezone change setting without reboot ?
Thanks
I could not find any way of changing timezone from cmd without causing a reboot.
Hi,
You could try:
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
in a cmd window.
or, just found out —> you can use the tzutil.exe in Windows 7.
tzutil /s “gmt standard time”
Changes the time zone to gmt and changes are instant.
Hope this helps.
Thank you for sharing this.