In python 3 how to get local zone name (e.g Australia/Sydney)
I tried like this
import datetimelocal_tzname = datetime.datetime.now().astimezone().tzinfoprint(local_tzname)
this outputs like this
AEDT
But I want to output like this which is the local time zone name
Australia/Sydney
I can execute timedatectl in a subprocess and read the output but that is not what I want.The script I am writing need to be executed on several RedHat (7/8/9) Ubuntu servers where I don't have control of available modules. Therefore it must use available modules when python 3 get installed.
Therefore my requirement is
- use native python 3 available modules
- not to use external commands and read the output (e.g. use subprocess )
- Not require any special module to be installed e.g. tzlocal
zoneinfo is a good module to work with IANA format but I couldn't use that to get the system time zone