I have a table to store machine start and stop records like that
---------------------------------------
| machine_start | machine_stop |
---------------------------------------
| 11:00 AM | 11:00 PM |
---------------------------------------
| 12:00 AM | 01:00 PM |
---------------------------------------
Now I want to get total machine operating time by first get the difference between machine_stop and machine_start time and loop through the table records to get the total time.
Here I have tried
$machine_total_time = 0;
foreach ($machine_data as $data){
$machine_total_time += strtotime($data->machine_stop) - strtotime($data->machine_start);
}
var_dump(date("H:i", $machine_total_time));
It will show the highest 23 hours for 'H'. I want to show the total hours and minutes from $machine_total_time. How to do that. Thanks.