Home >>Python Programs >Python program to print current hour, minute, second and microsecond
In this example, we will see a Python program through which we can print the current hour, minute, second and microseconds.
# Python program to print current hour,
# minute, second and microsecond
# importing the datetime class from
# datetime module
from datetime import datetime
# creating object
obj_now = datetime.now()
# printing the current date and time
print("Current date & time: ", obj_now)
# extracting and printing the current
# hour, minute, second and microsecond
print("Current hour =", obj_now.hour)
print("Current minute =", obj_now.minute)
print("Current second =", obj_now.second)
print("Current microsecond =", obj_now.microsecond)