0
Good afternoon, you guys.
I need to manipulate time fields [HH:MM:SS] in PHP itself.
I take the text values in the HTML form as in the following example:
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">P.E: <span data-toggle="tooltip" title=Horário de entrada" class="required">*</span></label>
<div class="col-md-9 col-sm-9 col-xs-12">
<input type="text" name="hora_entrada" class="form-control" data-inputmask="'mask' : '99:99:99'" placeholder="HH:MM:SS" required="">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">S.B.: <span data-toggle="tooltip" title="Horário de saída class="required">*</span></label>
<div class="col-md-9 col-sm-9 col-xs-12">
<input type="text" name="hora_saida" class="form-control" data-inputmask="'mask' : '99:99:99'" placeholder="HH:MM:SS" required="">
</div>
</div>
Bring to the PHP script to do the calculation:
$saida = $_POST['saida'];
$entrada = $_POST['entrada'];
//cálculo do hora trabalhada
$ps = strtotime($saida);
$pe = strtotime($entrada);
$horas = ($ps-$pe);
So if I put 14:20:00 - 06:00:00, the result should be 08:20:00
But it’s coming: 00:08:00
Does anyone know how I can make these calculations?
Thank you
With this data you test
$horas
is worth30000
, that is, the difference in seconds (which equals 8:20). I think it is correct.– rLinhares
It is that I would like the formatted value. Moreover, it shows 00:08:00 in the table field which is of the time type
– Isadora Almeida