Python 3 Find Difference Between Two Dates in Hours, Minutes & Seconds

code.py

import datetime
data1 = datetime.datetime.now()
data2 = datetime.datetime.now()

diff = data2 - data1

days, seconds = diff.days, diff.seconds
hours = days * 24 + seconds // 3600
minutes = (seconds % 3600) // 60
seconds = seconds % 60

print hours,minutes,seconds

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.