fork(4) download
  1. <?php
  2.  
  3. $date1 = new DateTime('2006-04-12T12:30:00');
  4. $date2 = new DateTime('2006-04-14T11:30:00');
  5. $interval = new \DateInterval('PT1H');
  6.  
  7. $periods = new \DatePeriod($date1, $interval, $date2);
  8. $hours = iterator_count($periods);
  9. echo $hours . ' hours';
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
47 hours