0
I’m trying to calculate a duration between column values in my database. The value until it is being calculated correctly, but it turns out that the hour:minute format is not going out as expected.
Assuming that in my database I have the first duration that is 1:30 and the second duration that is 2:30, will total 4:00 hours, but what comes out to me on screen is 4:0 of this format, how can I solve?
Follow below part of my code that makes the operation:
$query = mysql_query("SELECT ass.Duracao, pa.horas_dadas, pa.Horas_restantes, pa.Qtd_horas, ass.ID_Aluno, ass.ID_Pacote, ass.ID_Aula, pa.id_alunos FROM Assiste ass JOIN pacotes pa ON pa.ID=ass.ID_Pacote WHERE ID_Aluno = $pegaid AND ID_Pacote = $pegaid_pacote AND Status_presence = 'Ativa'"); 
while($row = mysql_fetch_array($query)) 
{ 
    $hora= $row['Duracao']; 
    $show_qtd_horas = $row['Qtd_horas']; 
    $hora1 = explode(":",$hora); 
    $min_hora1 = ($hora1[0] * 3600) + ($hora1[1] * 60); 
    $total=$total+$min_hora1; 
} 
$hora = floor($total / 3600); 
$total = $total - ($hora * 3600); 
$min = floor($total / 60)/10; 
$min=str_replace(".","",$min);
$result_duracao=$hora.":".$min; 
if(strlen($min)==1)
{ 
    $min=$min."0"; 
} 
$update_pacotes = mysql_query("UPDATE pacotes SET horas_dadas='$result_duracao' WHERE id_alunos=$pegaid AND ID=$pegaid_pacote");
echo $result_duracao;
How is the time saved in the Duration column? already in some format? H:mm || seconds?
– WMomesso