+ 2
How can i use a variable in python to show current time
2 Answers
+ 15
>>> import datetime
>>> datetime.datetime.now()
datetime(2009, 1, 6, 15, 8, 24, 78915)
And just the time:
>>> datetime.datetime.time(datetime.datetime.now())
datetime.time(15, 8, 24, 78915)
The same but slightly more compact:
>>> datetime.datetime.now().time()
To save typing, you can import the datetime object from the datetime module:
>>> from datetime import datetime
Then remove the leading datetime. from all the above.
SOURCE:
https://stackoverflow.com/questions/415511/how-to-get-current-time-in-JUMP_LINK__&&__python__&&__JUMP_LINK
+ 9
You can do it with the variables defined in the 'time' module.
https://code.sololearn.com/c94VEai1w7e3/?ref=app