CKTIS / Python
Module datetime
Represent dates, times, combined timestamps and durations.
Version: Python 3.14; repository image, production runtime not attested
Syntax
datetime.datetime.fromisoformat(text)Represent dates, times, combined timestamps and durations.
A timezone-aware datetime identifies a moment using its UTC offset, whereas a naive datetime lacks enough information to do so by itself. Converting a timestamp to UTC can change its calendar date.
Subtracting a naive datetime from an aware one raises TypeError.
Examples
import datetime
local = datetime.datetime.fromisoformat("2026-01-02T00:30:00+02:00")
utc = local.astimezone(datetime.UTC)
print(utc.isoformat(), local == utc)
try:
local - local.replace(tzinfo=None)
except TypeError:
print("mixed awareness")
Result
2026-01-01T22:30:00+00:00 True mixed awareness
Subtracting a naive datetime from an aware one raises TypeError.