October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Get the Current Date and Time in Python with datetime.now()

Use datetime.now() for local time, datetime.now(timezone.utc) for UTC, and datetime.now(ZoneInfo("Region/City")) for a named time zone, with the naive vs aware differences explained.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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, 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.

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:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Comparison and subtraction. Python raises a TypeError if 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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.