zope.datetime

raw JSON →
6.0 verified Mon Apr 27 auth: no python

Zope datetime provides timezone-aware datetime utilities, including timezone definitions and datetime parsing from common HTTP/email formats. Version 6.0 supports Python >=3.9 and is released periodically as part of the Zope Foundation libraries.

pip install zope.datetime
error ModuleNotFoundError: No module named 'zope.datetime'
cause Package installed as 'zope-datetime' but import path is 'zope.datetime'.
fix
Install the correct package: pip install zope-datetime
error AttributeError: module 'zope.datetime' has no attribute 'parse_datetime'
cause Function name is parseDatetimetz (CamelCase), not parse_datetime.
fix
Use: from zope.datetime import parseDatetimetz
error ValueError: unknown timezone offset
cause Parsing a timezone offset like 'Europe/Berlin' that isn't an integer offset.
fix
The function parseDatetimetz only handles ±HHMM offsets, not named timezones. Pre-process with pytz or zoneinfo.
breaking Version 6.0 requires Python >=3.9 and may have changed internal timezone handling. Code relying on pytz objects might break if now using zoneinfo.
fix Ensure compatibility: if using pytz, convert to zoneinfo or keep using pytz, but test edge cases.
gotcha Function parseDatetimetz does NOT parse all ISO 8601 strings; it only handles a subset (RFC 2822, RFC 850, ANSI C, and a few others).
fix Use dateutil.parser.isoparse or datetime.fromisoformat for general ISO 8601 parsing.
deprecated The module zope.datetime may be considered legacy; for new projects consider using dateutil or built-in zoneinfo (Python 3.9+).
fix Migrate to dateutil or built-in module.

Parse datetime strings using common formats.

from zope.datetime import parseDatetimetz
from datetime import datetime

# Parse an HTTP-date (RFC 1123)
dt = parseDatetimetz('Mon, 27 Apr 2026 12:00:00 GMT')
print(dt)  # timezone-aware datetime

# Parse a datetime with timezone offset
dt2 = parseDatetimetz('2026-04-27T12:00:00+02:00')
print(dt2)