PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteTo get the current date and time in Python, call datetime.now() from the standard-library datetime module. With no arguments it returns the current local date and time as a naive datetime object. To get the current time in UTC, pass timezone.utc, which returns an aware object. To get it in a named region such as Europe/Paris, pass a ZoneInfo object from the zoneinfo module.
Get the current local date and time
Import the class and call its now() method with no arguments:
As an Amazon Associate I earn from qualifying purchases.
from datetime import datetime
local_now = datetime.now()
print(local_now)
datetime.now() reads the clock of the machine running the code and reports the date and time in that machine’s local time zone. It is the most direct choice when the time is meant for the people or systems on that machine. Its result has tzinfo set to None, which makes it a naive value. The object does not say whether it represents local time, UTC, or another zone; the code calling it has to know that.
The Python documentation states that this function is preferred over today() and utcnow(). The same reference describes today() as equivalent in function, but it has no tz parameter, so it cannot be used for a specific zone.
#1 Best Overall
Get the current UTC time
For UTC, import timezone alongside datetime and pass timezone.utc:
from datetime import datetime, timezone
utc_now = datetime.now(timezone.utc)
print(utc_now.isoformat())
The result is aware: its tzinfo supplies a zero UTC offset, so the value can be compared with other aware datetimes and written out with its offset included. This is the form to use for logs, database timestamps, and APIs that expect UTC. The timezone class represents fixed offsets. It has no daylight-saving rules, which is fine for UTC but not for a city.
Rank #2
Get the current time in a named time zone
When the time should follow the civil rules of a region, including daylight-saving transitions, use ZoneInfo with an IANA time-zone key:
from datetime import datetime
from zoneinfo import ZoneInfo
paris_now = datetime.now(ZoneInfo("Europe/Paris"))
print(paris_now.tzname(), paris_now.utcoffset())
The offset returned for Paris changes between winter and summer time, and datetime.now() applies the offset in effect at the moment of the call. Pass a key from the IANA time-zone database, written as Region/City, such as America/New_York or Asia/Tokyo. Three-letter abbreviations like “EST” are not valid keys.
On Windows, Python does not always have a system copy of the IANA database. If ZoneInfo("Europe/Paris") raises an error saying the key was not found, install the tzdata package with pip install tzdata. The zoneinfo documentation describes this package as the fallback source of the database.
Choose the right expression
| Need | Expression | Result type |
|---|---|---|
| Current local date and time | datetime.now() |
Naive datetime |
| Current UTC date and time | datetime.now(timezone.utc) |
Aware datetime with a zero offset |
| Current time in a named region | datetime.now(ZoneInfo("Region/City")) |
Aware datetime following that region’s rules |
| Local date only, no time of day | date.today() |
Naive local date |
The table covers the common cases. Pick the row by what the value must mean to whoever reads it, not by which call looks shortest.
Naive and aware datetimes
A datetime is aware when its tzinfo is set to an object that supplies a UTC offset. Otherwise it is naive. The difference matters in three situations:
- Comparison and subtraction. Python raises a
TypeErrorif you compare or subtract a naive datetime with an aware one. - Serialization.
isoformat()on an aware value includes an offset such as+00:00. On a naive value it does not, so a reader may guess the zone wrongly. - Storage. A naive timestamp written to a database or file carries no zone information with it, so the zone must be recorded separately.
If the code needs a naive value that represents UTC, it is clearer to keep the aware value and remove the zone with replace(tzinfo=None) only at the point where a downstream system requires it, and to document that the stored value is UTC.
Best Value
Why not use datetime.utcnow()
Older tutorials use datetime.utcnow() to get UTC time. It returns a naive value, and the documentation warns that naive datetimes are often treated as local time. The method has been deprecated since Python 3.12. New code should use datetime.now(timezone.utc), which returns the same instant as an aware object. Existing code that calls utcnow() will still run on current versions, but it will emit a deprecation warning, and its results should be migrated to the aware form.
Repeated calls and clock precision
Two calls in quick succession can return the same value. The resolution of the underlying system clock determines how finely the time can be distinguished, so the returned microseconds are not guaranteed to change between calls. Do not rely on datetime.now() to produce unique or strictly increasing timestamps. If you need to measure elapsed time, use time.perf_counter() from the time module, which is designed for that purpose; datetime.now() is meant for reporting the date and time.
The full reference for these classes is in the Python datetime documentation, which is the Python 3.14.8 version of the page at the time of writing.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




