Clock in python

Share:

Print Year, Month, Day & time

Code:

import datetime

current_time = datetime.datetime.now()

print("The attributes of now() are : ")

print("Year : ", end = "")

print(current_time.year)

print("Month : ", end = "")

print(current_time.month)

print("Day : ", end = "")

print(current_time.day)

print("Hour : ", end = "")

print(current_time.hour)

print("Minute : ", end = "")

print(current_time.minute)

print("Second : ", end = "")

print(current_time.second)

print("Microsecond : ", end = "")

print(current_time.microsecond)

 

Output: 

The attributes of now() are :

Year : 2021

Month : 2

Day : 13

Hour : 0

Minute : 52

Second : 9

Microsecond : 986670