How do I calculate the difference in time in minutes for the following timestamp in Python?
2010-01-01 17:31:22 2010-01-03 17:31:22
To calculate with a different time date:
from datetime import datetime fmt = '%Y-%m-%d %H:%M:%S' d1 = datetime.strptime('2010-01-01 16:31:22', fmt) d2 = datetime.strptime('2010-01-03 20:15:14', fmt) diff = d2-d1 diff_minutes = diff.seconds/60