How to get current date and time in Python Programming

from datetime import datetime

now = datetime.now()

current_year = now.year

current_month = now.month

current_day = now.day

print(now)

print(now.year)

print (now.month)

print(now.day)

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

print('%s:%s:%s' % (now.hour, now.minute, now.second))

print("%s/%s/%s %s:%s:%s" % (now.month,now.year,now.year,now.hour, now.minute, now.second))

Leave a Reply

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