Python Calc time between two time stamps

Last Updated On Sunday 19th Dec 2021

Python Calculate Time between two time stamps.

  • time provides various time related functions.
  • time.sleep() Suspend execution of the calling thread for the given number of seconds.
  • datetime module to work with dates as date objects.
	from datetime import datetime
import time

  • import datetime and time
	date1 = datetime.datetime(2021, 6, 1)
date2 =

diff = date2 - date1


	15 days, 18:05:48.305102