How to get the pytz time zone from a common abbreviation (PST, EST, etc.)?

This is a similar question, How to get a common name for pytz timezone, for example. EST / EDT for America / New_York , except that I want to get the time zone from "PST" from pytz. e.g. tz = timezone("PST") Is this possible with pytz?

+8
python pytz
source share
2 answers

In the end, I just created a dictionary that displays abbreviations for time zone names. For example, 'PST' : 'America/Los_Angeles' is a record (like PDT to reduce daylight saving time).

+2
source share

Have you tried using strptime with% Z format code? I never did this myself, but at least in theory you would have to enter the tz code there, and it should be translated into tzinfo (built into the datetime / time object)

+1
source share

All Articles