3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dateRange = '2014-01-01 - 2014-01-08'; $parts = explode(' - ', $dateRange); $begin = new \DateTime($parts[0]); $end = new \DateTime($parts[1]); $interval = new \DateInterval('P1D'); $datePeriod = new \DatePeriod($begin, $interval, $end); $periodArray = iterator_to_array($datePeriod); /*$startDate = reset($periodArray); $endDate = end($periodArray);*/ $startDate = current($datePeriod); while($date = next($datePeriod)) { $endDate = $date; } #echo $datePeriod->start->format('c'); #echo "\n"; echo $startDate->format('c'); echo "\n"; #echo "\n"; #echo $datePeriod->end->format('c'); #echo "\n"; echo $endDate->format('c'); echo "\n"; echo "\n"; echo print_r($periodArray);
Output for 7.0.0 - 7.1.0
2014-01-01T00:00:00+01:00 Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/TsKdj:26 Stack trace: #0 {main} thrown in /in/TsKdj on line 26
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: Invalid operand type was used: expecting an array in /in/TsKdj on line 14 Warning: Invalid operand type was used: expecting an array in /in/TsKdj on line 15 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function format() on a non-object (boolean)' in /in/TsKdj:21 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.28
2014-01-01T00:00:00+01:00 Fatal error: Call to a member function format() on boolean in /in/TsKdj on line 26
Process exited with code 255.
Output for 5.3.27 - 5.3.29, 5.4.17 - 5.5.38
2014-01-01T00:00:00+01:00 Fatal error: Call to a member function format() on a non-object in /in/TsKdj on line 26
Process exited with code 255.
Output for 5.3.0 - 5.3.26, 5.4.0 - 5.4.16
Fatal error: Call to a member function format() on a non-object in /in/TsKdj on line 21
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 7 Fatal error: Class 'DateInterval' not found in /in/TsKdj on line 6
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 7 Fatal error: Class 'DateTime' not found in /in/TsKdj on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 7 Fatal error: Cannot instantiate non-existent class: datetime in /in/TsKdj on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/TsKdj on line 7 Fatal error: Cannot instantiate non-existent class: datetime in /in/TsKdj on line 4