Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find time difference in seconds as an integer with python

Tags:

python

I need to find the time difference in seconds with python. I know I can get the difference like this:

from datetime import datetime now = datetime.now() .... .... .... later = datetime.now() difference = later-now 

how do I get difference in total seconds?

like image 852
Richard Avatar asked Sep 03 '10 18:09

Richard


People also ask

How do you find the difference in time with seconds?

To get the total seconds between two times, you multiply the time difference by 86400, which is the number of seconds in one day (24 hours * 60 minutes * 60 seconds = 86400). Note.

How do I get the difference between two datetime objects in Python?

timedelta() method. To find the difference between two dates in Python, one can use the timedelta class which is present in the datetime library. The timedelta class stores the difference between two datetime objects.


1 Answers

import time now = time.time() ... later = time.time() difference = int(later - now) 
like image 158
Michael Mior Avatar answered Sep 23 '22 23:09

Michael Mior