Skip to main content

I'm looking for a programatic way to be able to set that setting in Date & Time. Any ideas?

Testing on 10.13.4 I also get the error mentioned by @shan3 .


It's a real shame the python code no longer works on 10.13.4 and above. This was a great find, but once again apple broken something useful.

On top of this I have noticed that this code no longer works on 10.13.3/10.13.4 and newer. I'm still looking into it, but no luck. /usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool YES

this command no longer ticks the option to set time zone automatically using current location


I get the opposite on 10.13.4, The box gets ticked, however the map does not show until I click on another tab


@ewinterbourne I'm still getting the same problem with that command in 10.13.5, Trying to find a way around it but no joy as of yet.


I have tried running this script in 10.14.1 and still getting no response from the machine when it comes to ticking the box, under Date & Time. Has anyone been able to find a resolution to this?


@oartola We've been using this https://github.com/jamfprofessionalservices/Jamf-Scripts/blob/master/Set%20Time%20Zone.sh Along with a self service policy.


I'm late to the party on this.

Did anyone ever figure out a fix for @NoahRJ 's script above to work properly in Mojave?

Also, @mack525 your link no longer works.


@DFree It must have been moved. Check out my Github page for the script


/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1

I'm using this as part of my enrollment provisioning on DEPNotify. When the user logs in, before DEPNotify launches, the time is PST. I prompt for reboot at the end of my DEPNotify script and after reboot, the location services kicks in and the time zone is automatically set by current location. It can take a few minutes for it to kick in


Create a blank package with the script below (postinstall). Then add it to your prestage enrollment.

#!/bin/bash


## configure ntp server

/bin/cat > /etc/ntp.conf << 'NEW_NTP_CONF'
server time.apple.com
NEW_NTP_CONF

## configure automatic timezone

/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1

uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57)
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1


## Set date and time automatically
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool YES
/usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeOnlyEnabled -bool YES
/usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeZoneEnabled -bool YES
/usr/sbin/systemsetup -setusingnetworktime on
/usr/sbin/systemsetup -gettimezone
/usr/sbin/systemsetup -getnetworktimeserver

### Restart location services daemon (locationd)
/usr/bin/killall locationd

exit 0;     ## Success
exit 1;     ## Failure

Modifying ByHost plist and those under /private/var/db has no effect. It doesn't toggle the checkbox in System Preferences. At least true for High Sierra, Mojave.