Python zoneinfo Module
Example
Work with time zones using IANA time zone database:
from datetime import datetime
from zoneinfo import ZoneInfo
dt = datetime(2025, 1, 15, 12, 0, tzinfo=ZoneInfo('America/New_York'))
print(f'New York time: {dt}')
tokyo = dt.astimezone(ZoneInfo('Asia/Tokyo'))
print(f'Tokyo time: {tokyo}')
Try it Yourself »
Definition and Usage
The zoneinfo module provides support for IANA time zone database, allowing you to work with time zones in a standard and reliable way.
Use it to convert between time zones, handle daylight saving time transitions, and work with historical time zone data.
Note: This module was introduced in Python 3.9 and replaces the older pytz package for many use cases.
Members
Member | Description |
---|---|
available_timezones() | Return a set of all available IANA time zone names. |
InvalidTZPathWarning | Warning raised when TZPATH contains an invalid path. |
reset_tzpath() | Reset the time zone search path to the default. |
ZoneInfo | Class representing an IANA time zone. |
ZoneInfoNotFoundError | Exception raised when a time zone cannot be found. |