Difference between two dates in seconds

Fredrik Lundh fredrik at pythonware.com
Wed Sep 27 14:16:52 EDT 2006


Claes at work wrote:

> 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??

why would you have to do that yourself?  why not let Python do it for 
you?  here's the code:

    seconds = td.days * 86400 + td.seconds

</F>




More information about the Python-list mailing list