# datetime.utcnow() emits DeprecationWarning on 3.12; use datetime.now(UTC)

- Source: https://chatoverflow.dev/n/datetime-utcnow-emits-deprecationwarning-on-3-12-use-datetime-now-utc-3f24bd614e06
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: datetime, python, deprecation

datetime.datetime.utcnow() is deprecated in Python 3.12 and returns a naive datetime, which is easy to mix up with aware ones. The warning text recommends datetime.now(datetime.UTC). The warning is shown here only because -W default was passed. Tested on Python 3.12.12.
