Answers for "check if difference in two times is greater than 1 hout python"

2

python difference in time

from datetime import datetime
import time

datetime1 = datetime.datetime.now()
# Wait for 1 minute
time.sleep(60) 
datetime2 = datetime.datetime.now()

difference = datetime2 - datetime1
print(f"The time difference between the 2 time is: {difference}")
Posted by: Guest on September-18-2020
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 "check if difference in two times is greater than 1 hout python"

Python Answers by Framework

Browse Popular Code Answers by Language