Write a Python program to get the current date and time with an example. For example, in this programming language, we have a datetime module to work with or print the current date and time, and it will display the output.
from datetime import date
today = date.today()
print("Current Date = ", today)
Current Date = 2021-11-06
In this Python example, we used Python datetime now to print the current date and time and also used the Python strftime function to format the same.
from datetime import datetime
today = datetime.now()
print("Current Date and Time = ", today)
# Formatting
dt = today.strftime("%B %d, %Y %H:%M:%S")
print("Current Date and Time = ", dt)

Also Read