Answer the question
In order to leave comments, you need to log in
How to count how many seconds have passed from a date to another?
I want to count how many seconds have passed since the given date 12:44:11 to 12:45:55 (hour, minute, second)
I want to know how many seconds have passed between them
How to do this?
Answer the question
In order to leave comments, you need to log in
Don't reinvent the wheel, use datetime.timedelta , that's what it was invented for.
import datetime
moment1 = datetime.datetime(2021, 9, 2, 12, 44, 11)
moment2 = datetime.datetime(2021, 9, 2, 12, 45, 55)
delta = moment2 - moment1
print(delta.total_seconds())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question