This question already has an answer here:
I have prob with the time after the subtraction to be inserted into database
$time = new DateTime('08:10:00');
$timein = new DateTime('17:05:00');
$newtime = $timein->diff($time);
$sql = "UPDATE staff_attendance SET total_working_time='$result' WHERE id='$a_id'";
</div>