I usually do it through the System Preference panel for Date & Time, but I'd like a quicker way to do this if there is one.
2 Answers
Use the following Terminal command:
sudo systemsetup -settimezone timezone
For a list of valid timezone
values, use sudo systemsetup -listtimezones
.
To get the current timezone, use:
sudo systemsetup -gettimezone
-
5And just for the record, you can also get the current timezone by doing
sudo systemsetup -gettimezone
. Commented Sep 8, 2014 at 13:25 -
4
-
-
1Sadly, this isn't working for me. It seems to change it (says
Set TimeZone: America/New_York
and returns exit code 0) but thensudo systemsetup -gettimezone
returns the previous value (Time Zone: America/Los_Angeles
). Commented Sep 2, 2016 at 17:38 -
2To get timezone without sudo, use
date +"%Z %z"
. This displays something likeEDT -0400
, the upper case z outputs the TZ abbreviation, lowercase the UTC offset. Commented Apr 3, 2020 at 17:08
Additionally:
Printing a random timezone:
ruby -e "puts `sudo systemsetup -listtimezones`.lines.sample.strip"
Setting a random timezone:
sudo systemsetup -settimezone (ruby -e "puts `sudo systemsetup -listtimezones`.lines.sample.strip")
Finding a timezone (e.g. containing "Los" in this case):
sudo printf ''; sudo systemsetup -listtimezones | grep Los
-
I wish I could upvote this for the random timezone trick. Alas, it does not answer the question, and should probably be a comment instead of an answer. Cool script though! Commented Jun 17, 2023 at 5:07