Time difference in seconds (as a floating point)

Posted by pocoa on Stack Overflow See other posts from Stack Overflow or by pocoa
Published on 2010-05-21T08:55:52Z Indexed on 2010/05/21 9:00 UTC
Read the original article Hit count: 184

Filed under:
|
|
>>> from datetime import datetime
>>> t1 = datetime.now()
>>> t2 = datetime.now()
>>> delta = t2 - t1
>>> delta.seconds
7
>>> delta.microseconds
631000

Is there any way to get that as 7.631000 ? I can use time module, but I also need that t1 and t2 variables as DateTime objects. So if there is a way to do it with datettime, that would be great.

© Stack Overflow or respective owner

Related posts about python

Related posts about floating-point