iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
To 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. To get it in a named region such as Europe/Paris, pass a ZoneInfo object. The rest of this guide explains which form to use, what the result contains, and the mistakes that produce wrong times.
Get the current local date and time
Import the datetime class and call its now() method:
from datetime import datetime
local_now = datetime.now()
print(local_now) # e.g. 2026-10-09 14:32:05.418213
print(local_now.tzinfo) # None
The value reflects the clock and time-zone setting of the machine running the code. If a server is set to UTC, the result is UTC; if a laptop is set to Berlin, the result is Berlin time. The tzinfo attribute is None, so the object does not record which zone it represents. This is what “naive” means in Python, and it is covered in more detail below.
Get the current UTC time
For timestamps that will be stored, logged, or compared across machines, use UTC. Pass timezone.utc, which is imported from the same module:
#1 Best Overall
from datetime import datetime, timezone
utc_now = datetime.now(timezone.utc)
print(utc_now) # e.g. 2026-10-09 12:32:05.418213+00:00
The result is an aware datetime. Its +00:00 suffix shows the offset, so the value can be converted or compared safely with other aware datetimes.
Get the current time in a named region
Use zoneinfo.ZoneInfo with an IANA time-zone name, such as "Europe/Paris", "America/New_York", or "Asia/Tokyo":
Rank #2
from datetime import datetime
from zoneinfo import ZoneInfo
paris_now = datetime.now(ZoneInfo("Europe/Paris"))
print(paris_now) # e.g. 2026-10-09 14:32:05.418213+02:00
A named region is the right choice when the time should follow that region’s civil-time rules, including daylight-saving transitions. The offset printed above will change automatically when the region switches between standard and summer time.
Two practical notes:
- On Windows, and on any system without an IANA time-zone database,
ZoneInfo("Europe/Paris")can raiseZoneInfoNotFoundError. Installing thetzdatapackage from PyPI supplies the data. - The built-in
timezoneclass represents a fixed offset only.timezone(timedelta(hours=2))will not change when daylight-saving time starts or ends, so useZoneInfofor regional times.
Choose the right expression
| Need | Expression | Result |
|---|---|---|
| Current local time | datetime.now() |
Naive datetime in the machine’s local time |
| Current UTC time | datetime.now(timezone.utc) |
Aware datetime with a +00:00 offset |
| Current time in a named region | datetime.now(ZoneInfo("Region/City")) |
Aware datetime following that region’s rules |
| Current local date only | date.today() |
A date object with no time of day |
Among the datetime constructors, the official reference says now() is preferred over today() and utcnow(). Unlike today(), now() accepts a tz argument, which is why it covers all three datetime cases above. Source: Python datetime documentation, Basic date and time types.
Naive and aware datetimes
Python distinguishes two kinds of datetime objects, and the difference affects what you can safely do with the result:
- Naive:
tzinfoisNone. The object holds a date and time but no reliable zone or offset.datetime.now()produces this kind. - Aware:
tzinfois set and supplies a UTC offset.datetime.now(timezone.utc)anddatetime.now(ZoneInfo(...))produce this kind.
Do not mix the two. Subtracting a naive datetime from an aware one, or ordering them with <, raises TypeError. Equality comparison returns False rather than raising an error, which can hide the mistake. If a function needs both, make them the same kind before combining them.
Common mistakes
Using datetime.utcnow() for new UTC code
datetime.utcnow() returns a naive value that holds UTC numbers. Because it has no zone information, the result is easy to treat as local time by mistake. The documentation has deprecated it since Python 3.12. Replace it with datetime.now(timezone.utc), which returns an aware UTC value.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems# Avoid in new code
old = datetime.utcnow()
# Use instead
new = datetime.now(timezone.utc)
Expecting every call to return a different instant
Two calls made in quick succession can return identical values if the operating system’s clock has limited resolution. Do not rely on now() to produce unique timestamps. If unique identifiers are needed, use a counter or a UUID instead.
Best Value
Treating a fixed offset as a region
Hard-coding an offset such as +01:00 for Paris gives the wrong time for part of the year, because regional offsets change with daylight-saving time. Use ZoneInfo("Europe/Paris") so the library applies the correct rules for each date.
Quick Recap
Reference: Python datetime documentation.
“
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.

