In the below example – we are implementing a python program to print current hour, minute, second and microsecond.
Steps:
- Import the datetime class from datetime module
- Create an object by calling the now() function of datetime class
- Extract and print the current hour, minute, second and microsecond using the object of datetime.now().