Tema: sumar horas
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/03/2007, 13:10
nrrivas
 
Fecha de Ingreso: febrero-2006
Mensajes: 5
Antigüedad: 18 años, 2 meses
Puntos: 0
Re: sumar horas

Muchas gracias, si funciono, pero tuve que hacerle algunos pequeños cambios:

Código PHP:
<?php
// Autor elkronos

function suma2horas($hora1,$hora2)
{
$totseg =0;$totmin=0;$tothora=0;
list(
$h1,$m1,$s1) = explode(":",$hora1);
list(
$h2,$m2,$s2) = explode(":",$hora2);

if((
$s1 $s2) > 59)
    {
        
$totseg $s1 $s2 60;
        
$totmin++;
    }
else
    {
        
$totseg $s1 +$s2;
    }
$totmin += $m1 $m2;
if(
$totmin 59)
    {
        
$totmin $totmin 60;
        
$tothora++;
    }
$tothora+= $h1 $h2;
return ((
strlen($tothora)==1)?"0$tothora":$tothora).":".( (strlen($totmin)==1)?"0$totmin":$totmin).":".((strlen($totseg)==1)?"0$totseg":$totseg);
}

// USO
echo suma2horas("01:59:59","03:59:59");
?>
Gracias nuevamente