When I subtract the time the result is "0" I want it to be in the time format, for example: 19:38:20 - 19:37:00 = 00:01:20.
Note: The "time" values of the database I'm assigning to "$ time1" and "$ time2" are in varchar format. I have already tested both and are in the correct format, but when subtracting it is not in the time format as stated before ...
code:
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<?php
include "../../conexao.php";
// primeira parte 1
$sql = "SELECT * FROM tempo";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$id = $row["id"];
$tempo1 = $row["tempo"];
$sql = "DELETE FROM tempo WHERE id='$id'";
if ($conn->query($sql) === TRUE) {
} else {
echo "Erro ao tentar deletar: " . $conn->error;
}
echo "$tempo1 <br>";
// segunda parte 2.2
$sql = "SELECT * FROM tempo2";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$id = $row["id"];
$corrida = $row["corrida"];
$nome1 = $row["nome"];
$numero = $row["numero"];
$tempo2 = $row["tempo"];
echo "$tempo2 <br>";
$sql = "DELETE FROM tempo2 WHERE id='$id'";
if ($conn->query($sql) === TRUE) {
} else {
echo "Erro ao tentar deletar: " . $conn->error;
}
$tempo = $tempo2 - $tempo1;
echo "$tempo <br>";
}
}