Harlin Seritt wrote: > How can I take a time given in milliseconds (I am doing this for an > uptime script) and convert it to human-friendly time i.e. "4 days, 2 > hours, 25 minutes, 10 seonds."? Is there a function from the time > module that can do this? > > Thanks, > > Harlin Seritt >
seconds = millis / 1000 # obviously minutes = seconds / 60 seconds %= 60 hours = minutes / 60 minutes %= 60 days = hours / 24 hours %= 24 All this using integer division, of course. This is probably much more verbose than the tersest soln, but it works (or should do - I haven't tested it). It's not strictly accurate (from a scientific/UTC perspective, as some minutes have 59 or 61 seconds rather than 60, but it's probably the best you need. --Max -- http://mail.python.org/mailman/listinfo/python-list