1import datetime
2start = datetime.datetime(2009,2,10,14,00)
3end = datetime.datetime(2009,2,10,16,00)
4delta = end-start
5print(str(delta))
6# prints 2:00:00
1def strfdelta(tdelta, fmt):
2 d = {"days": tdelta.days}
3 d["hours"], rem = divmod(tdelta.seconds, 3600)
4 d["minutes"], d["seconds"] = divmod(rem, 60)
5 return fmt.format(**d)