Skip to main content
1 of 2
user1876484
  • 337
  • 3
  • 14

Linux: robust way to get Timezone in form Continent/City

I'm looking for a portable/robust way to obtain timezone of a Linux box (mainly different versions of Debian) in form of Continent/City, like Europe/Kiev.

Till now I did it using timedatectl status | grep zone | cut -d' ' -f10 The problem with this approach is that it works on Debian 9, but not on Debian 10 (can easily be checked using docker images).

Is there a better, more universal/portable way to do this (better without scratching/parsing the output of another command)? If not, how should I modify the command above, so it works on both Debian 9 and 10.

user1876484
  • 337
  • 3
  • 14