Search code examples
pythondatetimetimezonepytz

Is there a simplified pytz common_timezone list?


I'm hoping someone has come up with something like this.

There's about 400+ timezones in the pytz.common_timezones list, and while that's great for accuracy, it's quite a bit too much to ask users to sift through.

See for instance, this timezone list from a forum I frequent (it's much more manageable)

enter image description here

Has anyone come up with a useful common_timezone list?


Solution

  • "Useful" is opinionated. Your opinions may not match with others'. For example, the list in your example doesn't have an entry for Arizona - which is not the same as just Mountain Time, as it doesn't have daylight saving time.

    The better approach is to offer two dropdowns. The first should list countries, and the second would list time zones within the country. Since many countries only have a single time zone, many users won't need to select time zones at all. Those that do can limit their choice to a much smaller list.

    In pytz, you can use the country_timezones function to get a list of time zones for a particular country.