Unlike the datetime and other date related objects in python, timedelta does not have any useful strong formatting options.
It also has no external method that can format it into something that you might want to present to an end user. As such, say you wanted Hours:Minutes:Seconds, you’d have to do some fancy things with the .seconds attribute on the timedelta.
To save time, the code for ‘fancy things’ is given below:
hours, remainder = divmod(duration_time_delta, 3600) minutes, seconds = divmod(remainder, 60) duration_formatted = '%s:%s:%s' % (hours, minutes, seconds)