Time Zones with zoneinfo
Work with aware datetimes.
Naive vs aware datetimes
A naive datetime has no timezone info — it just says '2 PM' with no clue which 2 PM. An aware datetime carries a timezone, so it pins down an exact moment worldwide.
Aware datetimes prevent bugs when users span multiple regions.
from datetime import datetime
naive = datetime(2026, 5, 30, 14, 0)
print(naive.tzinfo)Importing zoneinfo
Python 3.9+ ships zoneinfo in the standard library. Import ZoneInfo and pass an IANA timezone name like 'Europe/Istanbul' or 'America/New_York'.
from zoneinfo import ZoneInfo
tz = ZoneInfo('Europe/Istanbul')
print(tz)All lessons in this course
- date, time, datetime
- Timedelta and Arithmetic
- Formatting and Parsing
- Time Zones with zoneinfo