all Python 3datetimefunction
datetime.datetime.now()
datetime
Return the current date and time: naive local time by default, or an aware UTC object when called as datetime.now(timezone.utc).
Syntax
from datetime import datetime
datetime.now(tz=None)
A naive result cannot be subtracted from or ordered against an aware one — Python raises TypeError: can't subtract offset-naive and offset-aware datetimes, while == silently returns False — so pick one style and stick to it across the program. Also do not use now() to measure elapsed time: the system clock is adjusted by NTP and DST shifts, so use time.perf_counter() for durations.
Examples
from datetime import datetime, timezone
now = datetime.now()
print(now) # → ? текущий момент, например 2026-10-07 12:42:33.112969
print(now.hour, now.minute, now.second) # → ? например 12 42 33
utc = datetime.now(timezone.utc)
print(utc.tzinfo) # → UTC — осознанный объект
See also
Open in the full glossarydocs.python.orgReport an inaccuracy