Regd. converting seconds to hh:mm:ss format

Sick Monkey sickcodemonkey at gmail.com
Tue Feb 20 13:15:15 EST 2007


Do you mean epoch time?  if so, the below example would work.

>>> import time,datetime
>>> t = datetime.datetime.now()
>>> print t
2007-02-20 13:09:34.851000
>>> print "Epoch Seconds:", time.mktime(t.timetuple())
Epoch Seconds: 1171994974.0

# go the other way
>>> epochtime = 1171994974
>>> now = datetime.datetime.fromtimestamp(epochtime)
>>> print now
2007-02-20 13:09:34

On 2/20/07, Vishal Bhargava <vishal at veriwave.com> wrote:
>
>
> Is there an inbuilt library in Python which you can use to convert time in
> seconds to hh:mm:ss format?
> Thanks,
> Vishal
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070220/6258142d/attachment.html>


More information about the Python-list mailing list