Ver Mensaje Individual
  #6 (permalink)  
Antiguo 26/03/2019, 16:09
Avatar de Triby
Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: suma de array de horas

Código PHP:
Ver original
  1. function sumarHoras($horas) {
  2.     $total = 0;
  3.     foreach($horas as $h) {
  4.         $parts = explode(":", $h);
  5.         $total += $parts[2] + $parts[1]*60 + $parts[0]*3600;        
  6.     }  
  7.     $h = floor($total / 3600); // Calculas horas
  8.     $total -= $h * 3600;  // Restas al total
  9.     $m = floor($total / 60); // Calculas minutos
  10.     $s = $total - ($m * 60); // Calculas segundos restando minutos al total
  11.     return "$h:$m:$s";
  12. }
__________________
- León, Guanajuato
- GV-Foto