I have two date strings (taken from user input and can vary greatly)
s1 = \'2011:10:01:10:30:00\'
s2 = \'2011:10:01:11:15:00\'
I wish to fi
Use datetime to parse the string and convert into a base epoch time. Do the math. Convert back:
>>> from datetime import datetime
>>> s1 = '2011:10:01:10:30:00'
>>> s2 = '2011:10:01:11:15:00'
>>> d1=datetime.strptime(s1,'%Y:%m:%d:%I:%M:%S')
>>> d2=datetime.strptime(s2,'%Y:%m:%d:%I:%M:%S')
>>> d2-d1
datetime.timedelta(0, 2700)
>>> (d2-d1).total_seconds()/60
45.0
If you are looking for arbitrary date string parsing, check out DateUtil and the parse function.