The datetime.now() method from Python's datetime module returns a datetime object representing the current local date and time, including year, month, day, hour, minute, second, and microsecond. By default, it produces a naive object (without timezone information) in the format YYYY-MM-DD HH:MM:SS.microseconds.

To use this function, import the datetime class and call the method:

from datetime import datetime

# Get current date and time
now = datetime.now()
print(now)  # Output: 2025-06-08 14:30:45.123456

You can extract specific components using attributes or format the output using strftime():

  • Attributes: Access .year, .month, .day, .hour, .minute, .second, and .microsecond.

  • Formatting: Use now.strftime('%Y-%m-%d %H:%M:%S') for custom string formats.

  • Timezones: Pass a timezone object (e.g., datetime.now(timezone.utc)) to get a timezone-aware result.

  • Difference: It is similar to datetime.today(), but now() accepts an optional tz parameter for timezone handling.

Use datetime:

>>> import datetime
>>> now = datetime.datetime.now()
>>> now
datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)
>>> str(now)
'2009-01-06 15:08:24.078915'

For just the clock time without the date:

>>> now.time()
datetime.time(15, 8, 24, 78915)
>>> str(now.time())
'15:08:24.078915'

To save typing, you can import the datetime object from the datetime module:

from datetime import datetime

Then remove the prefix datetime. from all of the above.

Answer from Harley Holcombe on Stack Overflow
🌐
Python documentation
docs.python.org › 3 › library › datetime.html
datetime — Basic date and time types
As such, the recommended way to create an object representing the current time in UTC is by calling datetime.now(timezone.utc).
🌐
freeCodeCamp
freecodecamp.org › news › python-datetime-now-how-to-get-todays-date-and-time
Python Datetime.now() – How to Get Today's Date and Time
September 20, 2022 - You can use the datetime module in Python to retrieve data about date and time. In this article, you'll learn how to use the datetime object from the datetime module to get the current date and time properties. You'll also learn how to get the date and time of different locations around the world using the datetime.now() function and the pytz module.
🌐
X
x.com › realpython › status › 2013642771077243358
How to Get and Use the Current Time in Python
Build Physical Projects With Python on the Raspberry Pi — https://realpython.com/python-raspberry-pi/… #python ... Sign up now to get your own personalized timeline!
🌐
W3Schools
w3schools.com › python › python_datetime.asp
Python Datetime
import datetime x = datetime.datetime.now() print(x.year) print(x.strftime("%A")) Try it Yourself »
🌐
Python.org
discuss.python.org › python help
Datetime API: No atomic way to get "aware" current local datetime when moving between time zones - Python Help - Discussions on Python.org
June 5, 2024 - If I want to get a datetime instance that represents current local time and that is tagged with the current local timezone (i.e., an “aware” object), the recommended way to do this right now is as follows: from datetime import datetime datetime.now().astimezone() Now, if this code was to be executed on a mobile device that is physically moving across time zones, it is possible for the system time zone to change during program execution.
🌐
Educative
educative.io › answers › what-is-the-datetime-datetoday-function-in-python
What is the datetime date.today() function in Python?
In Python, there are multiple ways to extract the current date. In this shot, we will use the today() method from the date class of the datetime module. The datetime.now() method can extract the current date and time.
🌐
Python Guides
pythonguides.com › python-program-for-current-date-and-time
How To Get The Current Date And Time In Python?
December 17, 2024 - Read Convert Python String to Datetime with Timezone · By default, the datetime.now() method returns the current date and time based on your local time zone. However, if you need to work with different time zones, you can use the pytz module.
Find elsewhere
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-current-date-time
Python Current Date Time | DigitalOcean
August 3, 2022 - We can use Python datetime module to get the current date and time of the local system. from datetime import datetime # Current date time in local system print(datetime.now())
🌐
nixCraft
cyberciti.biz › nixcraft › howto › python › python get today’s current date and time
Python Get Today's Current Date and Time - nixCraft
August 6, 2024 - #!/usr/bin/python3 # Purpose: Python Current Date Time Demo # Author: nixCraft # -------------------------------------------- import time now = time.strftime("%c") ## date and time representation print ("Current date & time " + time.strftime("%c")) ...
🌐
PYnative
pynative.com › home › python › python datetime › how to get current date and time in python
Python Get Current Date and Time [8 Ways] – PYnative
December 5, 2021 - Python’s datetime module provides functions that handle many complex functionalities involving the date and time. Import the datetime class using a from datetime import datetime statement. ... The datetime.now() returns the current local date and time. By default, it represents datetime in ...
🌐
Codecademy
codecademy.com › docs › python › dates › datetime.now()
Python | Dates | datetime.now() | Codecademy
June 19, 2025 - The datetime.now() method is a class method from Python’s datetime module that returns a datetime object representing the current local date and time. This method captures the exact moment when it is called, including the year, month, day, ...
🌐
Mimo
mimo.org › glossary › python › datetime
Python datetime Module: Working with Dates, Times, and Formatting
Get Current Time with .now(): The datetime.now() method is the standard way to get the current local date and time. Use timedelta for Calculations: The timedelta object is essential for performing date arithmetic, such as adding or subtracting days, hours, or minutes from a datetime object.
🌐
SpeedySense
speedysense.com › home › python › how to get current date and time in python
How to get current date and time in Python - SpeedySense
November 9, 2020 - from datetime import datetime now = datetime.now() print (now.strftime("%Y-%m-%d %H:%M:%S")) print (now.strftime("%Y-%m-%d %I:%M:%S %p")) print (now.strftime("%a, %b %d, %Y")) print (now.strftime("%Y/%m/%d")) print (now.strftime("%I:%M:%S %p")) print (now.strftime("%H:%M:%S")) 2020-02-01 17:09:52 2020-02-01 05:09:52 PM Sat, Feb 01, 2020 2020/02/01 05:09:52 PM 17:09:52 · You can use the following list of directives to format the date and time with the strftime method. For more reference check it out datetime Objects in the datetime module from Python Standard Library Reference.
🌐
LearnByWatch
learnbywatch.com › python-datetime-now-guide
Python datetime.now(): A Beginner's Guide to Dates & Times - LearnByWatch
October 29, 2025 - Learn how to use Python datetime.now() to get the current date and time. This beginner's guide includes code examples for logging, formatting, and extracting components.
🌐
Programiz
programiz.com › python-programming › datetime
Python datetime (With Examples)
To learn more about strptime() and format codes, visit: Python strptime(). Suppose, we are working on a project and need to display date and time based on their timezone. Rather than trying to handle the timezone yourself, we suggest using a third-party pytZ module. from datetime import datetime import pytz local = datetime.now() print("Local:", local.strftime("%m/%d/%Y, %H:%M:%S")) tz_NY = pytz.timezone('America/New_York') datetime_NY = datetime.now(tz_NY) print("NY:", datetime_NY.strftime("%m/%d/%Y, %H:%M:%S")) tz_London = pytz.timezone('Europe/London') datetime_London = datetime.now(tz_London) print("London:", datetime_London.strftime("%m/%d/%Y, %H:%M:%S"))
🌐
SourceBae
sourcebae.com › home › how do i get the current time in python?
How do I get the current time in Python? - SourceBae
August 21, 2025 - To quickly retrieve the current date and time, Python provides the datetime.now() function.
🌐
Joelinoff
joelinoff.com › blog
Python datetime.datetime.now() that is timezone aware – Joe's Blog
August 4, 2012 - Pingback: Python – Create current datetime object with timezone | Eureka!
🌐
Code.mu
code.mu › en › python › manual › time › datetime › today
The today method of the datetime module - the current date in Python
method strftime of module datetime, which creates a formatted string with date and time · method now of module datetime, which returns the current time · method date of module datetime, which creates a new object with a date · method isleap of the calendar module, which determines a leap year ·
🌐
Luasoftware
code.luasoftware.com › tutorials › python › python-datetime-now-utc
Python Datetime Now Utc
Related articlesTypeError: can't subtract offset-naive and offset-aware datetimes (Python)Python Datetime Remove Millliseconds and Seconds (or time)Python Diff Between Two Dates (Days, Hours, Minutes, Seconds)Python TypeError: can't subtract offset-naive and offset-aware datetimesPython Check datetime With No/Zero/Midnight TimePython Replace Time in DatetimePython Get Today Date Without TimePython Convert UTC to TimezonePython Get Current Date & TimePython Parse String to datetimePython Format datetime