Calculating downtime?

0

I need to perform a calculation that returns me the number of hours a machine has stopped, in my database I have two data/minutos field, which are of date stop and return date , they are in the following format:

$dataParada = '201704120850' ;
$dataRetorno = '201704120955';

So far I can do the calculation with the following function:

$dataParada = '201704120850';
$dataRetorno = '201704120955';  

$datatime1 = new DateTime($dataParada);
$datatime2 = new DateTime($dataRetorno);


$data1  = $datatime1->format('Y-m-d H:i:s');
$data2  = $datatime2->format('Y-m-d H:i:s');  

$data1 = strtotime($data1);
$data2 = strtotime($data2);

$nHoras   = ($data2 - $data1) / 3600;
$nMinutos = (($data2 - $data1) % 3600) / 60;
$total = sprintf('%02d:%02d', $nHoras , $nMinutos);

echo $total;

The problem now is that I only need to take into account machine hours from 07:30 to 12:00 and 13: 30 at 17:48 , and disregard the Saturdays , Sundays and holidays .

>     
asked by anonymous 04.05.2017 / 21:00

0 answers