3v4l.org

run code in 300+ PHP versions simultaneously
<?php $begin = new DateTime( '2007-12-31' ); $end = new DateTime( '2009-12-31 23:59:59' ); $interval = DateInterval::createFromDateString('last thursday of next month'); $period = new DatePeriod($begin, $interval, $end, DatePeriod::EXCLUDE_START_DATE); foreach ( $period as $dt ) echo $dt->format( "l Y-m-d H:i:s\n" );
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Thursday 2008-01-31 00:00:00 Thursday 2008-02-28 00:00:00 Thursday 2008-03-27 00:00:00 Thursday 2008-04-24 00:00:00 Thursday 2008-05-29 00:00:00 Thursday 2008-06-26 00:00:00 Thursday 2008-07-31 00:00:00 Thursday 2008-08-28 00:00:00 Thursday 2008-09-25 00:00:00 Thursday 2008-10-30 00:00:00 Thursday 2008-11-27 00:00:00 Thursday 2008-12-25 00:00:00 Thursday 2009-01-29 00:00:00 Thursday 2009-02-26 00:00:00 Thursday 2009-03-26 00:00:00 Thursday 2009-04-30 00:00:00 Thursday 2009-05-28 00:00:00 Thursday 2009-06-25 00:00:00 Thursday 2009-07-30 00:00:00 Thursday 2009-08-27 00:00:00 Thursday 2009-09-24 00:00:00 Thursday 2009-10-29 00:00:00 Thursday 2009-11-26 00:00:00 Thursday 2009-12-31 00:00:00
Output for 5.2.0 - 5.2.17
Fatal error: Class 'DateInterval' not found in /in/gWNgO on line 5
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/gWNgO on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected ')', expecting '(' in /in/gWNgO on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected ')', expecting '(' in /in/gWNgO on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'('' in /in/gWNgO on line 6
Process exited with code 255.

preferences:
302.79 ms | 401 KiB | 457 Q