What is zoneinfo.available_timezones() in Python?

The zoneinfo module provides the available_timezones() function to get a set of all of the available time zones present in your system’s IANA database.

  • This set is recalculated for every call to the function.
  • The list may vary from system to system.
  • These are the keys that are passed to the ZoneInfo( key ) constructor.

Note: The zoneinfo module is only available in Python version 3.9 or higher.

Syntax

zoneinfo.available_timezones()

Parameters

This function does not accept any parameters.

Return value

The function returns a set of available time zones in the IANA database.

Example

In the example below, we:

  • Import zoneinfo.
  • Loop through the list returned by zoneinfo.available_timezones() and print out the timezones.
import zoneinfo
for key in zoneinfo.available_timezones():
print(key)

Free Resources