At the moment I have this code that is calculating the interval between the hours. I want to increment the calculation with minutes, and I want to make some changes in the logic, for example when I put the input time as 23 hours and output time as 12 hours the other day, it returns me 11 hours, and it should return 13 .
<?php
$hi = 23;
$hf = 12;
$total = -1;
$maior = calculaMaior($hi,$hf);
$menor = calculaMenor($hi,$hf);
for($i = $maior ; $i >= $menor ; $i--){
$total++;
echo"<br>$total<br>";//aqui ele irá mostrar todos os números só pra garantir
}
$aux = $maior + $total;
$total = $aux - $total;
echo "<br>**************$total*************";
function calculaMaior($n1, $n2){
if($n1 > $n2){
return $n1;
}else if($n1 < $n2){
return $n2;
}
}
function calculaMenor($n1, $n2){
if($n1 > $n2){
return $n2;
}else if($n1 < $n2){
return $n1;
}
}
?>