I have a method which takes two strings (times) e.g. 15:01
The method should take the times and do time1-time2 and return to me a new time in minutes.
eg. 15:53 - 15:59 should give me 6 minutes however i’m stuck.
This is my code:
import datetime
class timeCalc(object):
def timeDiff(self,time1,time2):
timeA = datetime.datetime.strptime(time1, "%H:%M")
timeB = datetime.datetime.strptime(time2, "%H:%M")
newTime = timeA - timeB
You function needs to
returnnewTime:Notes:
I think you want
newTime = timeB - timeAotherwise you have to pass the times in backwards like I did.