Difference Between Two datetimes
Ben Finney
ben+python at benfinney.id.au
Mon Dec 28 00:21:34 EST 2009
"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.
--
\ “Science doesn't work by vote and it doesn't work by |
`\ authority.” —Richard Dawkins, _Big Mistake_ (The Guardian, |
_o__) 2006-12-27) |
Ben Finney
More information about the Python-list
mailing list