codescracker


python

Python Program to Print Date and Time



« Previous Program Next Program »


Print Date and Time in Python

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.

Python Programming Code to Print Date and Time

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:

python print date and time

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test