I am trying to create a timesheet page where an employee can clock in and clock out. After they clock out, their total hours are calculated, hence, time2 (clock out) minus time1 (clock in). I used a set time here because I just want to know how to do the difference itself then I can figure out how to do the rest (everything else works except the total). I provided my code and the results. If you can solve the problem with the hours, I would appreciate it if you post the code and the results. Someone has suggested that I use abs() in line 54 but it still did not work. Thank you for your time.
$time1 = strtotime('09:10:04');
$time2 = strtotime('12:16:06');
$diff = $time2 - $time1;
echo "Start Time: ".date('h:i:s', $time1)."<br>";
echo "End Time: ".date('h:i:s', $time2)."<br>";
echo "Total hours: " . date('h:i:s', $diff);
Start Time: 09:10:04
End Time: 12:16:06
Total hours: 10:06:02