Date Time Library

Import the library

import datetime

 

Print the full date

now = datetime.now()
print(now)

 

Print the year, month, day, hour, minute, or second

now = datetime.now()
print(now)
print(now.year)
print(now.month)
print(now.day)
print(now.hour)
print(now.minute)
print(now.second)

 

Print the date in a different format

now = datetime.now()
print '%s/%s/%s' % (now.month, now.day, now.year)

Leave a Reply

Your email address will not be published. Required fields are marked *