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?
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.
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.
import time now = time.time() ... later = time.time() difference = int(later - now)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With