fork download
  1. <?php
  2.  
  3. $date1 = DateTime::createFromFormat("d/m/Y H:i:s", "06/05/15 08:34:32");
  4.  
  5. $date2 = DateTime::createFromFormat("d/m/Y H:i:s", "07/05/15 10:15:57");
  6.  
  7. $interval = $date1->diff($date2);
  8.  
  9. var_dump($interval->format("Le tout : %m mois, %d jours, %h heures, %i minutes, %s secondes"));
  10.  
  11. $totalHours = $interval->m * 730.4843 + $interval->d * 24 + $interval->h + 0.0166 * $interval->i + 0.0002 * $interval->s;
  12.  
  13. var_dump(sprintf("En heures : %s", $totalHours));
  14.  
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
string(60) "Le tout : 0 mois, 1 jours, 1 heures, 41 minutes, 25 secondes"
string(19) "En heures : 25.6856"