get todays date datetime code example

Example 1: find todays date in python

from datetime import datetime

# Current date time in local system
print(datetime.now())
print(datetime.date(datetime.now())) ##For Date

Example 2: datetime today

from datetime import datetime

# datetime object containing current date and time
now = datetime.now()
 
print("now =", now)

# dd/mm/YY H:M:S
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
print("date and time =", dt_string)

Example 3: get current date datetime

from datetime import date

today = date.today()
print("Today's date:", today)