Calculate time difference in minutes

Thursday, June 13, 2013


Below code will explain how to find a difference in the minute,
if you have two dates, then you can find the difference of the time using divmode function of python
 >>> import datetime  
 >>> end = datetime.datetime.now()  
 >>> start = datetime.datetime.now()  
 >>> diff  
 datetime.timedelta(0, 7, 424199)  
 >>> diff = start - end  
 >>> divmod(diff.days * 86400 + diff.seconds, 60)  
 (0, 7) # 0 minutes, 7 seconds  


AS answered on: http://stackoverflow.com/questions/17058863/calculate-time-difference-in-minutes/17059038#17059038