To print date and time in python, you have to first import the datetime library and use datetime.datetime.today() code inside the print() statement to print the today's current date and time as output as shown here.
Following python program prints the current date and time:
# Python Program - Print Date and Time import datetime while True: print("Want to print Today's Date and Time ? (y/n): ") check = input() if check == 'n': break else: print("Today's date and time:") print(datetime.datetime.today()) print()
Here is the sample run of the above python program to illustrate how to print current date and time:
You may also like to learn or practice the same program in other popular programming languages: