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.
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
. – XåpplI'-I0llwlg'I - Sep 8 '14 at 13:25 -
3
-
-
Sadly, 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
). – AlexChaffee Sep 2 '16 at 17:38 -
To 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. – Jon Church Apr 3 '20 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