简体   繁体   中英

Python : Epoch time issue

I have an issue

I have two epoch time like

endTime
1349351477198


startTime
1349351468952

I am getting the correct time format while checking it on http://www.epochconverter.com/

like

GMT: Thu, 04 Oct 2012 11:51:08 GMT

Thu, 04 Oct 2012 11:51:17 GMT

For the same epoch when i am trying to convert in time using python like (I am not taking care of date )

>>> start_time = time.strftime("%H:%M:%S", time.gmtime(1349351468952))
>>> print start_time 
20:29:12
>>> start_time = time.strftime("%H:%M:%S", time.gmtime(1349351477198))
>>> print start_time 
22:46:38

I am getting unexpected result as above please help me out .

I guess your problem is that your numbers are not in seconds but in milliseconds. Try this instead:

time.strftime("%H:%M:%S", time.gmtime(1349351477.198))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM