Im trying to subtract tow hours, this is my code (crono()
subtracts two hours):
include("classes/Functions.php");//contains crono()
include("classes/database.php");//database connection
$selectActual = "SELECT * from InfActual WHERE state='on'";
$resultActual = $conn->query($selectActual);
if ($resultActual->num_rows > 0) {
while ($rowActual = $resultActual->fetch_assoc()) {
$horaIni = $rowActual['horaIni'];
$actual = date("h:i:s");
echo "horaini: ".$horaIni." actual: ".$actual."<br>";
echo "subtract: ".crono($hora, $actual)."<br>";
}
}
And this is the result
horaini: 05:41:25 actual: 05:53:43
subtract: 05:53:43
I think the problem is that $rowActual['horaIni']
is not in the same format as $actual
(I'm not totally sure), I don't know how to solve this.
[Solved]
echo "subtract: ".crono($horaIni, $actual)."<br>";
Sorry, I'm so stupid, I'm not using
$horaIni
incrono()
function. So sorry.