Answers for "find difference between two dates python datetime"

1

get time between things python

>>> import datetime
>>> time1 = datetime.datetime.now()
>>> time2 = datetime.datetime.now() # waited a few minutes before pressing enter
>>> elapsedTime = time2 - time1
>>> elapsedTime
datetime.timedelta(0, 125, 749430)
>>> divmod(elapsedTime.total_seconds(), 60)
(2.0, 5.749430000000004) # divmod returns quotient and remainder
# 2 minutes, 5.74943 seconds
Posted by: Guest on December-01-2020

Code answers related to "find difference between two dates python datetime"

Python Answers by Framework

Browse Popular Code Answers by Language