0Pricing
Python Academy · Lesson

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

  1. date, time, datetime
  2. Timedelta and Arithmetic
  3. Formatting and Parsing
  4. Time Zones with zoneinfo
← Back to Python Academy