Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert microseconds into a human readable time

Tags:

python

time

I need to convert a time difference (diff) between two actions into a human readable time.

How can I do this with python? I tried something like

    diff = 49503757
    datetime.time(0,0,0,diff)

but the diff value was too long, the datetime expects a value of microseconds in between 0 and 999999 and my diff in this example was 49503757.

like image 975
Chris Avatar asked Jun 14 '12 12:06

Chris


1 Answers

>>> from datetime import timedelta
>>> str(timedelta(microseconds=49503757))
'0:00:49.503757'
like image 109
Burhan Khalid Avatar answered Sep 24 '22 05:09

Burhan Khalid