Good afternoon, guys.
I need to manipulate time fields [HH: MM: SS] in PHP itself.
I get the values in text 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>
I bring 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 do these calculations?
Thank you