Python Forum
Python convert duration in seconds to hh:mm:ss:ms
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python convert duration in seconds to hh:mm:ss:ms
#2
time.gmtime() dos not have milliseconds.
The term is seconds since the epoch: January 1, 1970, 00:00:00 (UTC).
>>> time.gmtime(audio.info.length)
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=3, tm_sec=53, tm_wday=3, tm_yday=1, tm_isdst=0)

>>> time.strftime('%H:%M:%S', time.gmtime(audio.info.length))
'00:03:53'
Don't use len as variable name.
Name it's used bye Python.
>>> len('hello')
5
Reply


Messages In This Thread
RE: Python convert duration in seconds to hh:mm:ss:ms - by snippsat - Dec-14-2017, 03:40 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020