3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dateRange = '2012-10-01 - 2014-01-20'; $parts = explode(' - ', $dateRange); $begin = new \DateTime($parts[0]); $end = new \DateTime($parts[1]); $interval = new \DateInterval('P1D'); $datePeriod = new \DatePeriod($begin, $interval, $end, DatePeriod::EXCLUDE_START_DATE); $periodArray = iterator_to_array($datePeriod); $startDate = reset($periodArray); $endDate = end($periodArray); #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');
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
2012-10-02T00:00:00+02:00 2014-01-19T00:00:00+01:00
Output for hhvm-3.10.0 - 3.12.0
2014-01-20T00:00:00+01:00 2014-01-20T00:00:00+01:00
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 7 Fatal error: Class 'DateInterval' not found in /in/FrbMH 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/FrbMH on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 7 Fatal error: Class 'DateTime' not found in /in/FrbMH on line 4
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 7 Parse error: syntax error, unexpected ')', expecting '(' in /in/FrbMH on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 7 Parse error: parse error, unexpected ')', expecting '(' in /in/FrbMH on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 5 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/FrbMH on line 7 Parse error: parse error, expecting `'('' in /in/FrbMH on line 7
Process exited with code 255.