Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xcsrz/e8dfa82d1222c0fff47427a5a0a034b3 to your computer and use it in GitHub Desktop.
Save xcsrz/e8dfa82d1222c0fff47427a5a0a034b3 to your computer and use it in GitHub Desktop.
Sometimes you just want a list of timezones with their offsets. From this you can find the offset for a given timezone on a specific date.
from datetime import datetime
import pytz
UTC = pytz.timezone("UTC")
for tzn in pytz.common_timezones:
tz = pytz.timezone(tzn)
print(
tzn,
UTC.localize(datetime(2020, 12, 15)).astimezone(tz).strftime('%z'),
UTC.localize(datetime(2020, 6, 15)).astimezone(tz).strftime('%z'),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment