I found this post that shows how to get the difference in hours between two dates.
The dates are: 2017-07-03 13:55:20 AND 2017-07-04 21:17:44
When I tried using this code it gives me wrong value:
$date1 = date_create('2017-07-03 13:55:20');
$date2 = date_create('2017-07-04 21:17:44');
$diff = date_diff($date1,$date2);
$hour = $diff->h;
returns 8 hours //incorrect
But this one gives me the correct value:
$hourdiff = round((strtotime('2017-07-03 13:55:20') - strtotime('2017-07-04 21:17:44'))/3600);
returns 31 hours //correct