calculate difference between two timestamps [newbie]

nukeymusic nukeymusic at gmail.com
Sat Dec 17 05:19:44 EST 2011


I'm trying to calculate the difference in seconds between two
timestamps, but I'm totally stuck:
date1="Dec-13-09:47:12"
date2="Dec-13-09:47:39"
>>> diff=datetime.date(date2)-datetime.date(date1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required

struct_date1=time.strptime(date1, "%b-%d-%H:%M:%S")
struct_date2=time.strptime(date2, "%b-%d-%H:%M:%S")
>>> diff=datetime.date(struct_date2)-datetime.date(struct_date1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required

thanks in advance
nukey



More information about the Python-list mailing list