Remove the time from this code.
Current Code:
from datetime import datetime, timedelta
date = datetime.today() - timedelta(days=1)
print("Today's date:", date)
Output:
Today's date: 2022-05-11 18:44:01.832558
Desired Output:
Today's date: 2022-05-11
CodePudding user response:
Your date
value is actually a datetime
object. Call date()
on it to convert it to just a date
:
>>> import datetime
>>> print(datetime.datetime.today().date())
2022-05-12