Skip to content

Instantly share code, notes, and snippets.

@ddre54
Last active July 16, 2024 17:15
Show Gist options
  • Save ddre54/1e217fbd7e28b5e864dfac31759e66e7 to your computer and use it in GitHub Desktop.
Save ddre54/1e217fbd7e28b5e864dfac31759e66e7 to your computer and use it in GitHub Desktop.
Mac OS X - Terminal commands for changing time zones in the machine
# Useful for testing things that are time zone
# sensitive - like scheduling things
# Get current timezone
sudo systemsetup -gettimezone
# Get list of available timezones
sudo systemsetup -listtimezones
# Set the timezone to the selected timezone
# sudo systemsetup -settimezone <timezone>
sudo systemsetup -settimezone America/New_York
sudo systemsetup -settimezone Europe/Paris
@Laicure
Copy link

Laicure commented Jul 13, 2024

Damn, thanks for this. I'm fairly new to MacOS and damn sheeeet changing the timezone makes me want to punch the Apple devs in their throats!

Anyway... Changing timezone in Windows was easy peasy like I live in GMT+8, I just need to select that. Then when working at night, I can just change it to PST (New York timezone). But in MacOS, "closest city"?! Where?! damn!

Sorry, rant over!

@holdfast-m
Copy link

I am a Seaman and right now we are UTC-11, I am using Apia with UTC+13, because there is no city with -11, also there is no city with UTC-9 (Honolulu -10, Anchorage -8), we will have utc-9 in 4 days, I do not want to "modify" time, only change time zone. And there is no "nearest city" in the middle of Pacific Ocean :)

@ddre54
Copy link
Author

ddre54 commented Jul 15, 2024

Hi @holdfast-m,

I did a quick check for the UTC-X time zones:

Overall, you could search in Google for a region with UTC-X in time zone, and then use the name to grep on the list of available time zones:

sudo systemsetup -listtimezones | grep -Ei "honolulu|anchorage|niue|samoa|alaska|gambier"

 America/Anchorage
 Pacific/Gambier
 Pacific/Honolulu
 Pacific/Niue

Note:

  • I haven't found how to correlate directly UTC-X to the list given by sudo systemsetup -listtimezones output, without querying external sources like Google yet.

@holdfast-m
Copy link

holdfast-m commented Jul 15, 2024

Good morning ddre54
No, there will be nolist by UTC... only google and manual check-out will give you the list but there exist DST (summer time) which is also linked to the city... so at winter it can be different timezone:)
When you set time like this (from terminal) for cities which not listed in common list (check "world time" section where you can add extra clock) and after you go to settings - date and time, you can see that the timezone city is Head office California (do not remember exactly) and you will not be able to change the timezone any more from settings window, only from terminal. You will be able to change it again by setting "approved list" city from terminal, then list from "settings window" will be restored back to normal.
But what to do with iphone or ipad? Over there I am not able to "cheat" like on mac🤔
"I have a dream" (C) that one day Apple will fix that🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment