3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = "2018-05-07"; $end = "2019-07-04"; $times = 0; // Check if first and last month in the range has a 14th. If(date("d", strtotime($start)) <= 14) $times++; If(date("d", strtotime($end)) >= 14) $times++; // Create an array with months between start and end $months = range(strtotime($start . "+1 month"), strtotime($end . "-1 month"), 86400*30); Var_dump($months); // Add the count of the months $times += count($months); Echo $times;
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
array(13) { [0]=> int(1528322400) [1]=> int(1530914400) [2]=> int(1533506400) [3]=> int(1536098400) [4]=> int(1538690400) [5]=> int(1541282400) [6]=> int(1543874400) [7]=> int(1546466400) [8]=> int(1549058400) [9]=> int(1551650400) [10]=> int(1554242400) [11]=> int(1556834400) [12]=> int(1559426400) } 14
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.3.32 - 7.3.33, 8.0.13
array(13) { [0]=> int(1528329600) [1]=> int(1530921600) [2]=> int(1533513600) [3]=> int(1536105600) [4]=> int(1538697600) [5]=> int(1541289600) [6]=> int(1543881600) [7]=> int(1546473600) [8]=> int(1549065600) [9]=> int(1551657600) [10]=> int(1554249600) [11]=> int(1556841600) [12]=> int(1559433600) } 14

preferences:
206.21 ms | 410 KiB | 5 Q