3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startTime = strtotime('2013-01-01 3:00'); $finishTime = strtotime('2013-03-01 3:00'); $lastMonthDay = strtotime(sprintf('last day of Jan'), $startTime); $dateTime = strtotime(sprintf('%s %s %s', 'Mon', '3:00', 'Jan'), $startTime); for (;$dateTime <= $lastMonthDay, $dateTime <= $finishTime; $dateTime = strtotime('+1 week', $dateTime)) { echo date ('d-m-Y H:i', $dateTime) . PHP_EOL; }
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.23, 7.0.0 - 7.0.20, 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
07-01-2013 03:00 14-01-2013 03:00 21-01-2013 03:00 28-01-2013 03:00 04-02-2013 03:00 11-02-2013 03:00 18-02-2013 03:00 25-02-2013 03:00

preferences:
253.66 ms | 405 KiB | 341 Q