fork(6) download
  1. <?php
  2.  
  3. function dtLength($sec)
  4. {
  5. $t=new DateTime("@".$sec);
  6. $r=new DateTime("@0");
  7. $i=$t->diff($r);
  8. $h=intval($i->format("%a"))*24+intval($i->format("%H"));
  9. return $h.":".$i->format("%I:%S");
  10. }
  11.  
  12. $date = new DateTime;
  13.  
  14. $tempo_1 = 10 * 3600; // 10 horas
  15.  
  16. $tempo_2 = 18 * 3600; // 18 horas
  17.  
  18. $tempo_3 = 28 * 3600; // 28 horas
  19.  
  20.  
  21. echo $date->setTime(0, 0, $tempo_1)->format('H:i:s'); // 10:00:00
  22.  
  23. echo $date->setTime(0, 0, $tempo_2)->format('H:i:s'); // 18:00:00
  24.  
  25. echo $date->setTime(0, 0, $tempo_3)->format('H:i:s'); // 04:00:00
  26.  
  27. echo dtLength($tempo_1);
  28. echo dtLength($tempo_2);
  29. echo dtLength($tempo_3);
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
10:00:0018:00:0004:00:0010:00:0018:00:0028:00:00