How do I set the timezone from command line ?
Asked Answered
S

4

38

How can I set the timezone in Windows from command line or from a batch file?

Do I need to use powershell or cscript?

Sphincter answered 20/5, 2013 at 18:45 Comment(0)
M
69

The command line utility that helps you change the time zone in Windows 7 is tzutil.exe and is known as Windows Time Zone Utility. This is a great tool for all the people who prefer working from the command prompt.

Use the /s parameter to set the time zone:

tzutil /s "universal standard time"

Use the /g parameter to get the time zone:

tzutil /g

Use the /l parameter to list the valid time zones.

tzutil /l

[source]

Mewl answered 20/5, 2013 at 18:47 Comment(2)
@IonicăBizău, Does this add a log in eventviewer like the "normal UI" does?Colocynth
Yes, this logs an event. You can set the time zone to whatever the current zone is to generate one.Athabaska
B
3

If anyone still uses Windows XP (as I do):

Step 1:

You can use the following command line, e.g. in the "Execute" window (cmd):

Control.exe TIMEDATE.CPL,,/Z W. Europe Standard Time

Where "W. Europe Standard Time" is, not really surprisingly, for Western Europe. Other possible values are e.g.

  • E. Europe Standard Time (for Eastern Europe)
  • Pazifik Standard Time (for what it says)

and so on. A list of possible values can be found here (although for Windows Vista, but it seems most values are the same):

https://technet.microsoft.com/en-us/library/cc749073%28v=ws.10%29.aspx

Step 2

In order to run the above command from a shortcut, you can do the following:

Create a new shortcut (e.g. in Windows explorer, right-click anywhere in an empty area, and choose "New shortcut") and give it the following value (by entering the code into the window that opens, or as "target" in the accordingly named field):

C:\Windows\System32\cmd.exe /c Control.exe TIMEDATE.CPL,,/Z W. Europe Standard Time

(The example uses W. Europe Standard Time; change this to your liking)

Calling this shortcut (i.e. clicking the Icon) immediately changes the timezone.

For my needs, I created two such shortcuts, one setting the timezone to Western Europe, the other setting it to Eastern Europe, as these are the locations where I am working regularly.

(Source for Step 2: Run a Command Prompt command from Desktop Shortcut)

Benefactor answered 10/8, 2015 at 10:36 Comment(3)
@Christian, Is there a way to set arbitrary timezones like +15:00 GMT?Colocynth
You mean, not calling specific time zone names (such as "Western Europe") but the time given in numbers (+15:00)?Benefactor
@ChristianGeiselmann, I mean arbitrary timezones that exist outside of specific time zone names. See this comment: #4977196 . E.g. +15:00 (note that there isn't really a +15:00) or +08:12Colocynth
A
2

If you have PowerShell 5.1, you have the equivalent of tzutil in PowerShell. For example, if you have Windows 10.

Examples:

See current time zone:

Get-TimeZone

See available time zones:

Get-TimeZone -ListAvailable

Set a time zone:

Set-TimeZone -Name "Georgian Standard Time"

Source: https://www.sysadmit.com/2019/08/cambiar-zona-horaria-Windows.html

Attenborough answered 18/8, 2019 at 20:8 Comment(0)
B
-2

Here is another answer to the initial question, related to Windows 7. This solution is completely based on Ionica Bizau's first contribution (see above). Essentially, I just added a step-by-step instruction for creating a batch file.

To create a batch file for setting time zones:

1) Create a text file in any text editor (PSPad, Notepad++, Notepad or whatever)

2) In the text file, write just one line of code. E.g. write

tzutil /s "GTB Standard Time"

which will set the time zone for Sofia, Bucharest, etc. Or use

tzutil /s "W. Europe Standard Time"

for places in the geographical longitudes of Amsterdam, Brussels, etc.

3) Save the file with a meaningful name such as "Set_TimeZone_W-Europe.bat". Make sure that the filetype suffix is ".bat". Save it at any place you like in your file system. You may choose your "Desktop" folder so to make the file available from your desktop screen.

4) That's it. Double-clicking the icon will trigger the (minimalistic) programme code to be executed, i.e. the system time will be set as desired.

Note: For my purposes, I made two such files, one for Western Europe, one for South East Europe, which are places I visit regularly.

If you need other time zones, look them up how they are named as follows:

a) Open the "Execute" window (cmd)

b) Type "tzutil /l" (without the quotation marks) and hit "return". This will display a list of available time zones.

Benefactor answered 8/2, 2016 at 21:59 Comment(2)
-1 this answer just adds unnecessary "fluff" to the accepted one, plus answers a completely unasked question "how to make a batch file", not to mention the inconsistent use of "quote marks" -- then, after much extended detail on which text editor to use, how to name my file, where to save it AND how to execute it, at step 4 I am informed to simply: Open the "Execute" window (cmd)Ashworth
Thanks for commenting. This detailed instruction was written for people with less computing experience than you. (It tackles issues I myself had with the original answer.) Therefore it includes some parts that you may well find too verbose (e.g. mentioning how to create a text file), but I am sure there are people to whom such redundance will be helpful. - As for your remark about quotation marks: I checked it again now, and I still found their use quite consistent. Perhaps you are used to other rules from your environment? In my, this is typographcally good practice.Benefactor

© 2022 - 2024 — McMap. All rights reserved.