Use strftime:

>>> from datetime import datetime
>>> datetime.today().strftime('%Y-%m-%d')
'2021-01-26'

To also include a zero-padded Hour:Minute:Second at the end:

>>> datetime.today().strftime('%Y-%m-%d %H:%M:%S')
'2021-01-26 16:50:03'

To get the UTC date and time:

>>> datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
'2021-01-27 00:50:03'
Answer from diegueus9 on Stack Overflow
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ library โ€บ datetime.html
datetime โ€” Basic date and time types
Such format values may raise an error as of Python 3.15. The workaround is to always include a year in your format. If parsing date_string values that do not have a year, explicitly add a year that is a leap year before parsing: >>> import datetime as dt >>> date_string = "02/29" >>> when = dt.date.strptime(f"{date_string};1984", "%m/%d;%Y") # Avoids leap year bug.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_datetime.asp
Python Datetime
The datetime() class requires three parameters to create a date: year, month, day.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ datetime โ€บ current-datetime
How to get current date and time in Python? (With Examples)
Here, we imported the date class from the datetime module. Then, we used the date.today() method to get the current local date.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ get-current-date-using-python
Get current date using Python - GeeksforGeeks
July 12, 2025 - The DateTime module provides some functions to get the current date as well as time. The today() method of date class under DateTime module returns a date object which contains the value of Today's date.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ get-current-date-and-time-using-python
How to Get Current Date and Time using Python - GeeksforGeeks
October 25, 2025 - datetime.now(tz=...) returns the current date and time as a timezone-aware datetime object.
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Get the Current Date and Time in Python: datetime.now, date ...
April 22, 2025 - datetime.date.today() โ€” Basic date and time types โ€” Python 3.13.3 documentation
Find elsewhere
๐ŸŒ
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 - In this article, we talked about getting today's date and time using the datetime.now() function in Python.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-the-datetime-datetoday-function-in-python
What is the datetime date.today() function in Python?
Line 2: We imported the date class from the datetime module. Line 4: We used the today() method to get the current local date.
๐ŸŒ
The Teclado Blog
blog.teclado.com โ€บ how-to-work-with-dates-times-python-datetime
Work with dates and times in Python using datetime
October 26, 2022 - With all that information, we can use a datetime object to refer to one particular moment in time. For example: import datetime today = datetime.datetime(year=2019, month=12, day=23, hour=11, minute=49, second=30) print(today) # 2019-12-23 11:49:30
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ datetime.date.today and timezones
r/learnpython on Reddit: datetime.date.today and timezones
October 19, 2021 -

I'm a student working on a Python project. In my code, I have a global variable:

today = date.today()

I am concerned with the date only, meaning I don't use time in my program. The only reason I would be concerned about time is for when it causes one today's date to switch to tomorrow's date.

Throughout my code, I reference this variable a bunch of times. For example:

  • today.day to get the current day of the month

  • today.strftime("%B") to get the current month name

  • today.year to get the current year, etc.

Recently, I have realized I need to deal with timezones. Upon looking up how to do this, I found some guides on how to use pytz. It seems fairly straightforward, however it all has to do with datetime.now() instead of date.today(), which I have been using throughout my code. I was hoping I could just swap in datetime.now(), but it messes things up because it has the date and the time, instead of just the date.

What is my best course of action? Is there a way for me to get date.today() to work with timezones/pytz, or do I need to re-work my code so that it can work with datetime.now()?

Hopefully this all makes sense. I just learned Python a few months ago. Thanks.

๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ datetime
Python datetime Module: Working with Dates, Times, and Formatting
from datetime import date # Get today's date today = date.today() # Create a specific date (year, month, day) my_birthday = date(1995, 5, 16) # Access individual components print("Year:", today.year) print("Month:", today.month) print("Day:", today.day) ... The time class represents the time ...
๐ŸŒ
Luasoftware
code.luasoftware.com โ€บ tutorials โ€บ python โ€บ python-get-today-without-time
Python Get Today Date Without Time
import datetimetoday = datetime.datetime.today()today = today.replace(hour=0, minute=0, second=0, microsecond=0)
๐ŸŒ
Datadog
docs.datadoghq.com โ€บ security โ€บ code_security โ€บ static_analysis โ€บ static_analysis_rules โ€บ python-best-practices โ€บ no-datetime-today
do not use datetime.today()
Using today() makes you think it only returns the year/month/day but it returns a full timestamp. For this reason, prefer using now(). from datetime import datetime print("foo") bla = datetime.today() # use datetime.now() instead
๐ŸŒ
AskPython
askpython.com โ€บ home โ€บ get current date and time in python
Get Current Date And Time in Python - AskPython
July 7, 2022 - The datetime module supplies classes for manipulating dates and times in Python. In the example below, we try to fetch the current date using the today() method from the date class.
๐ŸŒ
Centron
centron.de โ€บ startseite โ€บ python current date time โ€“ tutorial
Python Current Date Time - Tutorial
June 2, 2025 - In Python, we can use the datetime module to get the current date and time of the local system.
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ python-basic-exercise-3.php
Python: Print current time and date - w3resource
... The datetime module supplies classes for manipulating dates and times in both simple and complex ways. datetime.now(tz=None) returns the current local date and time. If optional argument tz is None or not specified, this is like today().
๐ŸŒ
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 - from datetime import date today = date.today() print('Current Date:', today) # Output 2021-07-16Code language: Python (python) Run
๐ŸŒ
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 - When you run the script you should see output as follows: $ python3 /path/to/script.py Outputs: Today's current date is - 2024-08-07 Date in dd/mm/YYYY format - 07/08/2024 Where, from datetime import date : The script first imports the date class from the datetime module.