3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (PHP_VERSION_ID !== 70300) { exit; } $begin = new DateTime('2019-03-25 20:34:56', new DateTimezone('UTC')); $end = new DateTime('2019-04-15 20:34:59', new DateTimezone('UTC')); $daterange1 = new DatePeriod($begin, new DateInterval('P1W'), $end); $daterange2 = new DatePeriod($begin, new DateInterval('P1W'), $end); echo loop($daterange1, 0), "\n\n"; //no pause echo loop($daterange2, 1); //1 second pause function loop($daterange, $sleep_int) { $count = 0; foreach ($daterange as $week) { echo "{$week->format('r')}\n"; $count++; sleep($sleep_int); //seconds } return $count; }
Output for 7.1.25 - 7.1.27, 7.2.0 - 7.2.33, 7.3.1 - 7.3.33, 7.4.0 - 7.4.30, 8.0.0 - 8.0.22, 8.1.0 - 8.1.9
Output for 7.3.0
Mon, 25 Mar 2019 20:34:56 +0000 Mon, 01 Apr 2019 20:34:56 +0000 Mon, 08 Apr 2019 20:34:56 +0000 Mon, 15 Apr 2019 20:34:56 +0000 4 Mon, 25 Mar 2019 20:34:56 +0000 Mon, 01 Apr 2019 20:34:56 +0000 Mon, 08 Apr 2019 20:34:56 +0000
Process exited with code 137.

preferences:
39.01 ms | 410 KiB | 5 Q