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.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
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.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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 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:
90.36 ms | 402 KiB | 202 Q