datetime.datetime.now() vs datetime.datetime.utcnow()
datetime.datetime.now() and datetime.datetime.utcnow() are both Python Datetime Module APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. datetime.datetime.now(): Returns the current local date and time with optional timezone. Its syntax is datetime.datetime.now(tz=None), and it returns datetime object datetime.datetime.utcnow(): Returns the current UTC date and time (deprecated, use now(timezone.utc)). Its syntax is datetime.datetime.utcnow(), and it returns datetime object (naive) Example of datetime.datetime.now(): from datetime import datetime
datetime.now() # datetime(2026, 6, 6, 14, 30, 0). Example of datetime.datetime.utcnow(): datetime.utcnow() # datetime(2026, 6, 6, 6, 30, 0). Read the full references for datetime.datetime.now() and datetime.datetime.utcnow() to see parameters, edge cases, and example code side by side. Other Datetime Module APIs worth comparing: datetime.date(), datetime.date.today(), datetime.datetime.fromtimestamp(), datetime.datetime.strptime(), datetime.datetime.strftime(), datetime.timedelta(). Both belong to the Datetime Module category in the Python Reference documentation.