Python ProgrammingPython Programming

Python difference between two dates in minutes

from datetime import datetime

fmt = '%Y-%m-%d %H:%M:%S'
d1 = datetime.strptime('2010-01-01 17:31:22', fmt)
d2 = datetime.strptime('2010-01-03 17:31:22', fmt)

days_diff = d2 - d1
print(days_diff.days * 24 * 60)
Output
2880