29

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 2

50

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
6
  • 5
    And just for the record, you can also get the current timezone by doing sudo systemsetup -gettimezone. Sep 8, 2014 at 13:25
  • 4
    is there a way to get the timezone without root?
    – cavalcade
    Feb 28, 2015 at 7:16
  • How can I update NTP source from CLI?
    – Quanlong
    Dec 3, 2015 at 3:44
  • 1
    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). Sep 2, 2016 at 17:38
  • 2
    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, 2020 at 17:08
-1

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
1
  • 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!
    – Dykotomee
    Jun 17, 2023 at 5:07

You must log in to answer this question.

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