Converting milliseconds to human time

Paul Rubin http
Sat Jan 7 03:27:31 EST 2006


"Harlin Seritt" <harlinseritt at yahoo.com> writes:
> I would like to take milliseconds and convert it to a more
> human-readable format like:
> 
> 4 days 20 hours 10 minutes 35 seconds

# To iterate is human; to recurse, divine.
def dhms(m,t):
   if not t: return (m,)
   return rl(m//t[0], t[1:]) + (m % t[0],)

human_readable = '%d days %d hours %d minutes %d seconds'% \
   dhms(msec//1000, (60, 60, 24))



More information about the Python-list mailing list