Python Glossary Русский

Python 3.9+zoneinfoterm

zoneinfo

module

IANA time zones for datetime: ZoneInfo("Europe/Berlin") with daylight saving transitions handled.

Syntax

import zoneinfo

zoneinfo provides real time zones by IANA database name and replaces the third-party pytz; with it datetime handles daylight saving time and historical offset changes itself. datetime.timezone only suits a fixed offset such as UTC+3 and knows nothing about transitions. The zone database comes from the system, and Windows has none — install the tzdata package there, or you get ZoneInfoNotFoundError.

Examples

from datetime import datetime
from zoneinfo import ZoneInfo
tz = ZoneInfo("Europe/Berlin")  # → ? нужна база часовых поясов tzdata
print(datetime(2026, 1, 15, tzinfo=tz).utcoffset())  # → 1:00:00
print(datetime(2026, 7, 15, tzinfo=tz).utcoffset())  # → 2:00:00

See also

Open in the full glossarydocs.python.orgReport an inaccuracy