If you want the current date and time in Python, the simplest answer is datetime.now(). In this tutorial, I’ll show you the right way to get local time, UTC, and timezone-aware timestamps, along with the formatting and pitfalls you should know.
Python datetime module
Python gives you the datetime module in the standard library, so you do not need to install anything extra. This module is the main tool for working with dates and times in Python.
Here is the import I’ll use throughout this tutorial:
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
Get the current date and time
If I just want the current local date and time on my machine, I use datetime.now().
from datetime import datetime
current_datetime = datetime.now()
print(current_datetime)
Example output:
2026-05-20 12:47:51.911708
You can see the output in the screenshot below.

This gives me the current local time with microseconds. It is the quickest and most common starting point.
Get only the current date
Sometimes I do not need the time part at all. In that case, I use date() on the datetime object.
from datetime import datetime
today = datetime.now().date()
print(today)
Example output:
2026-05-20
You can see the output in the screenshot below.

This is useful for reports, logs, reminders, and simple date-based filters.
Get only the current time
If I only want the time, I can use time().
from datetime import datetime
current_time = datetime.now().time()
print(current_time)
Example output:
20:38:12.345678
This is handy when I want to show just the clock time in a UI or log message.
Format the output
Raw datetime output is fine for debugging, but for users, I usually format it. I use strftime() to control how the date and time look.
from datetime import datetime
now = datetime.now()
formatted = now.strftime("%A, %B %d, %Y %I:%M %p")
print(formatted)
Example output:
Wednesday, May 20, 2026 12:50 PM
You can see the output in the screenshot below.

Common format codes I use a lot:
%Y= 4-digit year.%m= month number.%d= day of month.%H= 24-hour clock.%I= 12-hour clock.%M= minutes.%S= seconds.%p= AM/PM.
Get UTC
If I am building something serious, I usually store time in UTC first. That makes life easier when the app grows, users are in different states, or servers run in different regions.
from datetime import datetime, timezone
utc_now = datetime.now(timezone.utc)
print(utc_now)
Example output:
2026-05-17 15:08:12.345678+00:00
This is better than guessing local time when I need consistent timestamps for logs, APIs, and databases.
Use timezone-aware time
A timezone-aware datetime knows which timezone it belongs to. That matters a lot in real applications.
from datetime import datetime
from zoneinfo import ZoneInfo
new_york_time = datetime.now(ZoneInfo("America/New_York"))
print(new_york_time)
Example output:
2026-05-17 11:08:12.345678-04:00
For a US audience, this is a useful example because America/New_York is a common reference point. I can swap it with America/Chicago, America/Denver, or America/Los_Angeles depending on the use case.
Naive vs aware datetime
This is one of the most important ideas in Python datetime work.
- A naive datetime has no timezone information.
- An aware datetime includes timezone details.
from datetime import datetime, timezone
naive_time = datetime.now()
aware_time = datetime.now(timezone.utc)
print(naive_time)
print(aware_time)
Use naive datetimes only when timezone truly does not matter. For most real apps, I prefer aware datetimes because they are safer for logging, storage, and conversions.
Which method should I use?
When I choose a datetime method, I think about the job first.
| Need | Best choice | Why |
|---|---|---|
| Quick local timestamp | datetime.now() | Simple and familiar. |
| UTC timestamp for storage | datetime.now(timezone.utc) | Consistent across systems. |
| Specific US timezone | datetime.now(ZoneInfo(“America/New_York”)) | Correct local time for that region. |
| Display-friendly output | strftime() | Makes the timestamp readable. |
If I am building an app, I usually store UTC and convert to the user’s timezone only when I show it on screen.
Real-world examples
Here are a few places where this comes up all the time.
- Logging: I timestamp events so I can trace bugs later.
- Scheduling: I compare the current time against a job run time.
- APIs: I store request times and response times.
- Reports: I group records by date.
- Notifications: I send reminders based on the user’s local time.
A simple example for a US business app might look like this:
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
created_at_utc = datetime.now(timezone.utc)
display_time = created_at_utc.astimezone(ZoneInfo("America/Chicago"))
print("Stored in UTC:", created_at_utc)
print("Shown in Chicago time:", display_time)
That pattern is practical because it keeps storage clean and the user-facing display accurate.
Common mistakes
I see the same mistakes again and again when people work with dates and times.
- Using local time for storage instead of UTC.
- Mixing naive and aware datetime objects.
- Using datetime.utcnow() for new code when datetime.now(timezone.utc) is clearer.
- Forgetting that time zones change with daylight saving time.
- Hardcoding time strings instead of formatting them properly.
If the goal is production code, I avoid these problems early.
pytz or zoneinfo
If the code is on modern Python, I prefer zoneinfo. It is built into Python and works well for timezone-aware datetimes.
I would use pytz only when I am maintaining older code that already depends on it. For new projects, zoneinfo is the cleaner choice.
Final example
Here is a small, complete example you can reuse:
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
now_local = datetime.now()
now_utc = datetime.now(timezone.utc)
now_new_york = datetime.now(ZoneInfo("America/New_York"))
print("Local:", now_local)
print("UTC:", now_utc)
print("New York:", now_new_york)
print("Formatted:", now_new_york.strftime("%A, %B %d, %Y %I:%M %p"))
This gives me local time, UTC, a US timezone example, and a readable, formatted string in one place.
Conclusion
The easiest way to get the current date and time in Python is datetime.now(), but the better long-term habit is to use timezone-aware datetime objects when the code matters. If I am building something real, I store UTC, convert to the user’s timezone when needed, and format the result only for display.
You may also like to read:
- Python Hello World Program in Visual Studio Code
- Identifiers in Python
- Python If Not Statement
- Python Pass by Reference

Bijay Kumar is an experienced Python and AI professional who enjoys helping developers learn modern technologies through practical tutorials and examples. His expertise includes Python development, Machine Learning, Artificial Intelligence, automation, and data analysis using libraries like Pandas, NumPy, TensorFlow, Matplotlib, SciPy, and Scikit-Learn. At PythonGuides.com, he shares in-depth guides designed for both beginners and experienced developers. More about us.