+ 2

How can i use a variable in python to show current time

26th Apr 2018, 7:25 PM
Teddy
Teddy - avatar
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
26th Apr 2018, 8:22 PM
Baraa AB
Baraa AB - avatar
+ 9
You can do it with the variables defined in the 'time' module. https://code.sololearn.com/c94VEai1w7e3/?ref=app
26th Apr 2018, 7:35 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar