I have DateTime, from string I convert them on IS0 format example. ISODate("2016-06-24T09:07:31.097Z")
I want to find the differences between them using python, so I did this:
string_older = "2016-05-18T20:53:43.776456"
string_young = "2016-05-16T20:53:43.776456"
datetime_older = datetime.datetime.strptime(string_older, "%Y-%m-%dT%H:%M:%S.%f") //date on ISO format
datetime_young = datetime.datetime.strptime(string_young, "%Y-%m-%dT%H:%M:%S.%f") //date on ISO format
a = time.mktime(datetime_older)
b = time.mktime(datetime_young)
diff = a - b
seconds = int(diff) % 60
But this gives this error TypeError: argument must be 9-item sequence, not datetime.datetime
at this line time.mktime(datetime_older).
I don't know how to fix it? Please help.
time.mktimeat all. You have datetimes already, you can subtract them from each other.