Non-sudo Alternatives to Get Current Time Zone on macOS

command lineterminaltimetimezone

sudo systemsetup -gettimezone will return the current system set time zone to the command line but it requires sudo.

date "+%z" will return the offset (e.g. +0900) and date "+%Z" will return the time zone short code (e.g. JST).

Is there another way, either command, executable or API? My searches have turned up nothing. I'm writing a CLI terminal program (not Objective-C/Swift) within which it would be helpful to have access to whatever the system currently is set to.

Any help or insight will be much appreciated.

Best Answer

/etc/localtime is a symlink pointing to the currently used timezone. So you can use

$ readlink /etc/localtime
/var/db/timezone/zoneinfo/Europe/Istanbul
$ readlink /etc/localtime | sed 's#/var/db/timezone/zoneinfo/##g'
Europe/Istanbul

Note: sudo systemsetup -gettimezone prints Time Zone: Europe/Istanbul for me.