Difference Between Two datetimes

W. eWatson wolftracks at invalid.com
Mon Dec 28 01:43:47 EST 2009


Ben Finney wrote:
> "W. eWatson" <wolftracks at invalid.com> writes:
> 
>> How do I get the strings into a shape that will accommodate a difference?
>>
>> For example,
>> t1=datetime.datetime.strptime("2009/01/02 13:01:15","%y/%m/%d %H:%M:%S")
>> doesn't do it.
>> ValueError: time data did not match format:  data=2009/01/02 13:01:15
>> fmt=%y/%m/%d %H:%M:%S
> 
> As the error message indicates, the data input (the string) doesn't
> match the specified format.
> 
> See the time format specifications at the ‘time.strftime’ documentation
> <URL:http://docs.python.org/library/time.html#time.strftime>. Note
> especially that ‘%y’ and ‘%Y’ are distinct.
> 
Yes, see my response to the post above yours.



More information about the Python-list mailing list