# Create datetime objects for each time (a and b)
dateTimeA = datetime.datetime.combine(datetime.date.today(), a)
dateTimeB = datetime.datetime.combine(datetime.date.today(), b)
# Get the difference between datetimes (as timedelta)
dateTimeDifference = dateTimeA - dateTimeB
# Divide difference in seconds by number of seconds in hour (3600)
dateTimeDifferenceInHours = dateTimeDifference.total_seconds() / 3600
$start = new DateTime('2011-12-31 00:00:00');
$end = new DateTime('2021-01-01 00:00:00');
echo $end->getTimestamp() - $start->getTimestamp(); // output: 284169600