i want to find the time difference between two time in python. this is my code i got a type error. is this FMT is correct for this datetime?
import time
from datetime import datetime
s1=datetime.now()
print s1
time.sleep(2)
s2=datetime.now()
print s2
FMT = '%Y-%m-%d %H:%M:%s'
tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
print tdelta
output is:
2014-12-31 17:33:59.692952
2014-12-31 17:34:01.695124
Traceback (most recent call last):
File "/opt/odoo/trial_projects/check.py", line 14, in <module>
tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
TypeError: must be string, not datetime.datetime