Is there a list of Pytz Timezones? Is there a list of Pytz Timezones? python python

Is there a list of Pytz Timezones?

You can list all the available timezones with pytz.all_timezones:

In [40]: import pytzIn [41]: pytz.all_timezonesOut[42]: ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', ...]

There is also pytz.common_timezones:

In [45]: len(pytz.common_timezones)Out[45]: 403In [46]: len(pytz.all_timezones)Out[46]: 563

Don't create your own list - pytz has a built-in set:

import pytzset(pytz.all_timezones_set)  >>> {'Europe/Vienna', 'America/New_York', 'America/Argentina/Salta',..}

You can then apply a timezone:

import datetimetz = pytz.timezone('Pacific/Johnston')ct =>>> ct.isoformat()2017-01-13T11:29:22.601991-05:00

Or if you already have a datetime object that is TZ aware (not naive):

# This timestamp is in UTCmy_ct = Now convert it to another timezonenew_ct = my_ct.astimezone(tz)>>> new_ct.isoformat()2017-01-13T11:29:22.601991-05:00

The timezone name is the only reliable way to specify the timezone.

You can find a list of timezone names here: that this list contains a lot of alias names, such as US/Eastern for the timezone that is properly called America/New_York.

If you programatically want to create this list from the zoneinfo database you can compile it from the file in the zoneinfo database. I don't think pytz has an API to get them, and I also don't think it would be very useful.