Answers for "get the year date time python"

11

get the current year in python

import datetime
now = datetime.datetime.now().year
print(now)
Posted by: Guest on May-12-2020
0

time date year python

import datetime

now = datetime.datetime.now()

print(str(now.day).zfill(2)+'-'+str(now.month).zfill(2)+'-'+str(now.year)+' '+str(now.hour).zfill(2)+':'+str(now.minute).zfill(2)+':'+str(now.second).zfill(2))
# Output
# 24-05-2021 17:09:45
Posted by: Guest on May-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language