Difference between two dates in seconds

Claes at work claesatwork at gmail.com
Wed Sep 27 14:12:23 EDT 2006


Hi,

I am learning Python and want to perform what I think is a very simple
task: calculating the difference between two dates in seconds. Reading
through the documentation I am puzzled: I can't find a way to do this
without doing manually what I think  belongs to a standard library
method.

Please tell me there is a simpler way than subtracting two datetimes
to get a timedelta and then compute

days * number of seconds per day + seconds

from it myself??

Put in other words - I find it puzzling that timedelta exposes its
internal representation (the instance attributes days and seconds) but
not ways to get the difference in arbitrary units. What am I missing?

Thanks, Claes



More information about the Python-list mailing list