3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $recurrences = 4; $iso = 'R4/2012-07-01T00:00:00Z/P7D'; // All of these periods are equivalent. $p = new DatePeriod($start, $interval, $recurrences); //$p = new DatePeriod($start, $interval, $end); //$p = new DatePeriod($iso); foreach ($p as $d) { echo $d->format('d '); } echo "\n"; $p = \PHP_VERSION_ID >= 70107 ? clone $p : new \DatePeriod( $p->getStartDate(), new \DateInterval($p->getDateInterval()->format('P%yY%mM%dDT%hH%iM%sS')), $p->getEndDate() ?: $p->recurrences, (int) $p->include_start_date ) ; foreach ($p as $d) { echo $d->format('d '); }
based on agfao
Output for 7.1.7 - 7.3.0rc3
01 08 15 22 29 01 08 15 22 29
Output for 5.6.20 - 5.6.30, 7.0.5 - 7.1.6
01 08 15 22 29 08 15 22 29 05
Output for 5.6.5 - 5.6.19, 7.0.0 - 7.0.4
01 08 15 22 29
Process exited with code 139.
Output for hhvm-3.15.4
01 08 15 22 29 Notice: Undefined property: DatePeriod::$include_start_date in /in/hX9KD on line 26 01 08 15 22 29
Output for 5.6.0 - 5.6.4
01 08 15 22 29 Fatal error: Call to undefined method DatePeriod::getStartDate() in /in/hX9KD on line 23
Process exited with code 255.