22

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.

36

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
5
  • 5
    And 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
    is there a way to get the timezone without root? – cavalcade Feb 28 '15 at 7:16
  • How can I update NTP source from CLI? – Quanlong Dec 3 '15 at 3:44
  • Sadly, this isn't working for me. It seems to change it (says Set TimeZone: America/New_York and returns exit code 0) but then sudo 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 like EDT -0400, the upper case z outputs the TZ abbreviation, lowercase the UTC offset. – Jon Church Apr 3 '20 at 17:08
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .