I need to get time in python and i am using time.ctime()
and it returns this Thu Jul 8 15:37:26 2021
But i only need 15:37:26 and i cant figure out how to get only this and not the date and year.
I already tried using datetime where i could not figure it out either so im trying with time now.
here is a bit of code for the context:
JavaScript
x
5
1
cas = time.ctime()
2
cas = str(cas)
3
api.update_status('nyni je:'+ cas )
4
time.sleep(60)
5
Anyone know how to do it?
Advertisement
Answer
JavaScript
1
3
1
import datetime
2
print(datetime.datetime.now().strftime("%H:%M:%S"))
3