Python 3.9+zoneinfofunction
zoneinfo.available_timezones()
time zones
Returns a set of all IANA time zone keys available on the system, such as 'Europe/Moscow'.
Syntax
zoneinfo.available_timezones() -> set[str]
It returns a set, not a list, so use sorted() to show it to users. Every call walks the file system again and is expensive; store the result instead of calling it in a loop. The contents depend on the machine: on Windows without the tzdata package the set is empty.
Examples
import zoneinfo
zones = zoneinfo.available_timezones()
print(type(zones).__name__) # → set
print('Europe/Moscow' in zones) # → ? True при наличии базы
print(len(zones)) # → ? зависит от версии базы
See also
Open in the full glossarydocs.python.orgReport an inaccuracy