I need to calculate the adhesion between two workloads.
- Load 1: Load carried out is the end time - the start time
- Load 2: Scheduled load is the scheduled end time - the scheduled start time.
I gave a print in the data:
Realizado: 2016-10-24 15:10:00 - 2016-10-24 07:39:12 = Carga1: 07:30:48
Programado: 15:10:00 - 07:00:00 = Carga2: 08:10:00
Percentual: 0.875
* The format of the realized comes with date and the programmed only the time, I tried to leave both in the same format but did not work.
I'm going down this path:
$date1 = strtotime($ponto_inicio);
$date2 = strtotime($ponto_fim);
$realizado = date( 'H:i:s', abs( $date2 - $date1 ) );
$date3 = strtotime($hora_inicio);
$date4 = strtotime($hora_fim);
$programado = date( 'H:i:s', abs( $date4 - $date3 ) );
$percentual = $realizado / $programado;
The results of 100% are ok but when it comes out the result is always 0.95 por exemplo
for cases of the same and different programmed time.
What's wrong?