To get the seconds between two dates in Python you can use the following snippet.

Sample Python

import datetime
import time

def DateDiffSeconds(dateOlder, dateNewer):
  timedelta = dateNewer - dateOlder
  return timedelta.days*24*3600 + timedelta.seconds

dateOlder = datetime.datetime(2014,07,01,00,00,00)
dateNewer = datetime.datetime(2014,07,02,11,30,00)
print DateDiffSeconds(dateOlder,dateNewer)

One thought on “How to get the seconds between two dates in Python”

Leave a Reply