I have the following php code:
<?php foreach($rst_vis as $registro): ?>
<tr>
<td><h6><?php echo $i; $i++; ?></h6></td>
<td>
<h6><?php echo $registro->placa ?></h6>
</td>
<td>
<h6><?php echo $registro->fecha1 ?></h6>
</td>
<td>
<h6><?php echo $registro->fecha2 ?></h6>
</td>
<td>
<h6><?php
if($registro->accion>1){
$entrada = new DateTime($registro->fecha1); //campo DateTime de mysql
$salida = new DateTime($registro->fecha2); //campo DateTime de mysql
$diferencia = $entrada->diff($salida);
$horas=0; $minutos=0; $cadena="";
if(($diferencia->d)>0){
$horas = ($diferencia->d) * 24;
}
$horas = $diferencia->h; //horas
$minutos = $diferencia->i; //minutos
if($horas>0){
$cadena = $horas . " h ";
}
if($minutos>0){
$cadena = $cadena . $minutos . " m";
}
echo $cadena;
<?php endforeach; ?>
It is an entry control. In mysql I save in a field DateTime
, the date-time of entry and exit, then I take out the time interval to show it.
The problem is that it works locally on my computer, but when uploading it to the server, it does not work. The code stops on the first line. I do not know if there is something wrong with that statement. Thanks.