all Python 3deprecated in 3.12datetimefunction
datetime.datetime.utcnow()
datetime
Return the current UTC time as a naive object (no tzinfo), which is easy to confuse with local time. Deprecated since Python 3.12 — use datetime.now(timezone.utc).
Syntax
from datetime import datetime
datetime.utcnow() # deprecated, 3.12+
The real hazard is not the deprecation but that the naive result is silently treated as local time downstream: utcnow().timestamp(), or comparing it with datetime.now(), is off by exactly your UTC offset. When you meet it in existing code, replace it with datetime.now(timezone.utc) and expect the new object to carry tzinfo and to append '+00:00' in isoformat().
Examples
from datetime import datetime, timezone
old = datetime.utcnow() # naive, устарело
print(old.tzinfo) # → None (нет пояса!)
new = datetime.now(timezone.utc) # современный аналог
print(new.tzinfo) # → UTC
See also
Open in the full glossarydocs.python.orgReport an inaccuracy