Write a Python program to get current date and time with an example. For example, in Python, 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
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)