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 useNote:
sudo systemsetup -gettimezone
printsTime Zone: Europe/Istanbul
for me.