Friday, 15 July 2016

Python: time.localtime : Convert seconds to struts_time tuple in local time


time.localtime([secs]) is used to convert given seconds to local time. If seconds is not provided, then the current time returned by time() is used.
>>> import time
>>> 
>>> time.localtime()
time.struct_time(tm_year=2015, tm_mon=11, tm_mday=10, tm_hour=11, tm_min=1, tm_sec=48, tm_wday=1, tm_yday=314, tm_isdst=0)
>>> 
>>> time.localtime(0)
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=5, tm_min=30, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)
>>> 
>>> time.localtime(1000000000)
time.struct_time(tm_year=2001, tm_mon=9, tm_mday=9, tm_hour=7, tm_min=16, tm_sec=40, tm_wday=6, tm_yday=252, tm_isdst=0)
>>> 
>>> time.localtime(10000000000)
time.struct_time(tm_year=2286, tm_mon=11, tm_mday=20, tm_hour=23, tm_min=16, tm_sec=40, tm_wday=5, tm_yday=324, tm_isdst=0)
>>> 
>>> time.localtime(100000000000)
time.struct_time(tm_year=5138, tm_mon=11, tm_mday=16, tm_hour=15, tm_min=16, tm_sec=40, tm_wday=2, tm_yday=320, tm_isdst=0)



Previous                                                 Next                                                 Home

No comments:

Post a Comment