from datetime import datetime
start_date = 'Sun Sep 16 16:05:15 +0000 2012'
end_date = 'Sun Sep 17 23:55:20 +0000 2012'
def __datetime(date_str):
return datetime.strptime(date_str, '%a %b %d %H:%M:%S +0000 %Y')
start = __datetime(start_date)
end = __datetime(end_date)
delta = end - start
print(delta)
print(delta.total_seconds())
hours = (delta.total_seconds())/3600
print("Hours %s" % hours)
minutes = (delta.total_seconds())//3600
print("minutes %s" % minutes)
print(divmod(delta.total_seconds(), 3600))
h, m = divmod(delta.total_seconds(), 3600)
print(h)
print(m)
M, s = divmod(m, 60)
print(M)
print(s)