Difference Between Two datetimes

Stephen Hansen apt.shansen at gmail.com
Mon Dec 28 00:10:52 EST 2009


On Sun, Dec 27, 2009 at 8:54 PM, W. eWatson <wolftracks at invalid.com> wrote:

> That's fine, but I'd like to start with two dates as strings, as
> "1961/06/16 04:35:25" and "1973/01/18 03:45:50"
>
> 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
>

%y is a two-digit year, %Y is a four-digit year.

HTH,

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091227/8067907b/attachment-0001.html>


More information about the Python-list mailing list