php get number of hours between two dates code example
Example 1: calculate total time from start and end datetime in php
date1 = new DateTime('2006-04-12T12:30:00');
$date2 = new DateTime('2006-04-14T11:30:00');
$diff = $date2->diff($date1);
$hours = $diff->h;
$hours = $hours + ($diff->days*24);
echo $hours;
Example 2: get hours difference between two dates in php
$hourdiff = round((strtotime($time1) - strtotime($time2))/3600, 1);