Friday 15 July 2016

Python: time.time(): Get current time


‘time.time()’ returns current time in seconds.
>>> import time
>>> now=time.time()
>>> now
1447084433.208804
>>> 
>>> time.localtime(now)
time.struct_time(tm_year=2015, tm_mon=11, tm_mday=9, tm_hour=21, tm_min=23, tm_sec=53, tm_wday=0, tm_yday=313, tm_isdst=0)
>>> 
>>> 
>>> time.gmtime(now)
time.struct_time(tm_year=2015, tm_mon=11, tm_mday=9, tm_hour=15, tm_min=53, tm_sec=53, tm_wday=0, tm_yday=313, tm_isdst=0)



Previous                                                 Next                                                 Home

No comments:

Post a Comment