how to change the secs to the ISO time format?
Question: How to change the secs to the ISO time format:

for example:

28800 sec is the offset from the midnight? if successfully converted, the
output should be 08:00:00 not 8:00:00.

How could I do it in python? Thank you.


Answer: Solution using timedelta to 'do the math'

    
    
    from datetime import datetime, timedelta
    
    # Can easily get the values for today programmatically
    # but ommitted here for brevity
    midnight = datetime(2013, 10, 18)
    delta = timedelta(seconds=28800)
    
    offset_time = midnight + delta
    print offset_time.strftime('%H:%M:%S')
    
    >>> 08:00:00
    

