fork(2) download
  1. <?php
  2.  
  3. $horas = array(
  4. '-05:00:00',
  5. '08:00:00'
  6. );
  7.  
  8. $seconds = 0;
  9.  
  10. foreach ( $horas as $hora )
  11. {
  12. list( $g, $i, $s ) = explode( ':', $hora );
  13. if ($g < 0) {
  14. $i *= -1;
  15. $s *= -1;
  16. }
  17. $seconds += $g * 3600;
  18. $seconds += $i * 60;
  19. $seconds += $s;
  20. }
  21.  
  22. $hours = floor( $seconds / 3600 );
  23. $seconds -= $hours * 3600;
  24. $minutes = floor( $seconds / 60 );
  25. $seconds -= $minutes * 60;
  26.  
  27. echo "{$hours}:{$minutes}:{$seconds}";
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
3:0:0