How to print current time in python?
![](https://pythonpoint.net/wp-content/uploads/2020/12/Pink-and-Blue-Abstract-Moms-Influencer-Freestyle-Art-YouTube-Channel-Art-2-1024x576.jpg)
We can get the time by importing a library datetime.
from datetime import datetime t=datetime.now() current=t.strftime("%h:%m:%s") print(current)
![This image has an empty alt attribute; its file name is Screenshot-948-1024x484.png](https://pythonpoint.net/wp-content/uploads/2020/12/Screenshot-948-1024x484.png)
import time t=time.localtime() current=time.strftime("%H:%M:%S",t) print(current)
![This image has an empty alt attribute; its file name is Screenshot-950-1024x518.png](https://pythonpoint.net/wp-content/uploads/2020/12/Screenshot-950-1024x518.png)
This is how we can print current time in python.
Subscribe
Login
Please login to comment
0 Discussion