Time Difference In Seconds (as A Floating Point)
>>> from datetime import datetime >>> t1 = datetime.now() >>> t2 = datetime.now() >>> delta = t2 - t1 >>> delta.seconds 7 >>>
Solution 1:
for newer version of Python (Python 2.7+ or Python 3+), you can also use the method total_seconds
:
from datetime importdatetimet1= datetime.now()
t2 = datetime.now()
delta = t2 - t1
print(delta.total_seconds())
Solution 2:
combined = delta.seconds + delta.microseconds/1E6
Post a Comment for "Time Difference In Seconds (as A Floating Point)"