Python datetime with US Eastern timezone using zoneinfo

Want a #Python datetime with a timezone? Use the "zoneinfo" module: import zoneinfo tz = zoneinfo.ZoneInfo('US/Eastern') Then pass it to the "tzinfo" keyword arg: dt = datetime.datetime(2026, 4, 1, 13, tzinfo=tz)

  • No alternative text description for this image

Oooh, shiny. We used `pytz` for our project when I was at Meta. I remember making an active decision to use `pytz` over `zoneinfo`, in 2024, but I annoyingly can't remember why. Think we might have still been on 3.8 at the time. Anyway I remember dealing with all our time conversions being off by seven minutes... still traumatised. Seems like there's no good reason to use `pytz` over `zoneinfo` these days. https://www.reddit.com/r/Python/comments/1kxxgf9/python_timezone_conversion_gotcha_zoneinfo_vs_pytz/

To view or add a comment, sign in

Explore content categories