Skip to content

Instantly share code, notes, and snippets.

@ddre54
Last active May 13, 2024 02:36
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
@holdfast-m
Copy link

Good morning.
Hope that you still alive:)
Have a question, is it possible to set up timezones without knowing the city? For example I am in the middle of Pacific Ocean, our ship's time is UTC-11, I have no idea which city is that, or in that city there are DST active, but onboard we have our own time. And after 2 days that time will be again shifted, it will become either UTC+12 (minus one hour, but plus one day), or UTC-12, or UTC-10. Or we are not in Pacific, somewhere in Indian Ocean, and the time is UTC+6, I really have no idea which cities has this time. For win/android there are no such problems, 'cos there you see UTC list.

@ddre54
Copy link
Author

ddre54 commented May 14, 2023

Hi @holdfast-m,

Yes, I'm alive and well, thank you for your concern 👍

That's not something I've done or familiar with, but here are some pointers you could look deeper into:

  • Look into this other Gist thread, they seem to set it to the UTC through symlink.
    The thing you will have to look more into detail here is how to set the -12 part and such from UTC-12
    Set Time zone in OSX to UTC

  • Setting it to GMT (which is similar to UTC)

sudo systemsetup -settimezone GMT
  • If you have internet access you can look into set the time server:
# Displays whether network time is on or off.
# Network Time: On
sudo systemsetup -getusingnetworktime

# Displays the currently set network time server.
# Network Time Server: time.apple.com
sudo systemsetup -getnetworktimeserver

# Sets whether using network time is on or off.
sudo systemsetup -setusingnetworktime on

# Use this command to designate a network time server.  Enter the IP address or DNS name for the network time server.
sudo systemsetup -setnetworktimeserver timeserver

I hope this helps

If you find the proper solutions please let me know.

@holdfast-m
Copy link

Thanks!
Looks like the only way is to have a list all the cities with time zone mark in front of each city, or at least witn minimum 24+ with daylight saving time info.
Online update from internet will not help, because sometimes we have different timezone with does not matching with ship's position (longitude) so automatic GPS timezone also will not match. The only way is to change timezone manually.
Apple does not support such commands like ... "-settimezone GMT-08", or similar variations, because it is not from the "list".
Having MAC makes me crazy:) but that's new experience:)
All the best to You! Stay healthy!

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