3v4l.org

run code in 300+ PHP versions simultaneously
<?php //get First day of Month //get Last day of Month $first_day_of_month = mktime(0,0,0,date('n'),1,date('Y')); $last_day_of_month = mktime(23,59,59,date('n'),date('t'),date('Y')); echo "First Day of Month: "; echo $first_day_of_month; echo "<br />"; echo "Last Day of Month: "; echo $last_day_of_month; $datetest = array('04-02-2015','11-30-2014', '11-31-2014', '11-08-2014', '11-8-2014', '11-9-2014', '11-11-2014', '11-24-2014', '11-1-2014', '10-30-2014', '12-1-2014', '11-1-1997'); echo "<br /><br />\n\n"; foreach ($datetest as $datetest) { $split_date = explode("-",$datetest); $comp_date = mktime(0,0,0,$split_date[0],$split_date[1],$split_date[2]); if (($comp_date >= $first_day_of_month) && ($comp_date <= $last_day_of_month)){ echo "$datetest :"; echo " Is in Month!"; echo "<br />\n"; } else { echo "$datetest :"; echo "Not in Month!"; echo "<br />\n"; } }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 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.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
First Day of Month: 1427839200<br />Last Day of Month: 1430431199<br /><br /> 04-02-2015 : Is in Month!<br /> 11-30-2014 :Not in Month!<br /> 11-31-2014 :Not in Month!<br /> 11-08-2014 :Not in Month!<br /> 11-8-2014 :Not in Month!<br /> 11-9-2014 :Not in Month!<br /> 11-11-2014 :Not in Month!<br /> 11-24-2014 :Not in Month!<br /> 11-1-2014 :Not in Month!<br /> 10-30-2014 :Not in Month!<br /> 12-1-2014 :Not in Month!<br /> 11-1-1997 :Not in Month!<br />
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 First Day of Month: 1427839200<br />Last Day of Month: 1430431199<br /><br /> 04-02-2015 : Is in Month!<br /> 11-30-2014 :Not in Month!<br /> 11-31-2014 :Not in Month!<br /> 11-08-2014 :Not in Month!<br /> 11-8-2014 :Not in Month!<br /> 11-9-2014 :Not in Month!<br /> 11-11-2014 :Not in Month!<br /> 11-24-2014 :Not in Month!<br /> 11-1-2014 :Not in Month!<br /> 10-30-2014 :Not in Month!<br /> 12-1-2014 :Not in Month!<br /> 11-1-1997 :Not in Month!<br />
Output for 7.3.32 - 7.3.33, 8.0.13
First Day of Month: 1427846400<br />Last Day of Month: 1430438399<br /><br /> 04-02-2015 : Is in Month!<br /> 11-30-2014 :Not in Month!<br /> 11-31-2014 :Not in Month!<br /> 11-08-2014 :Not in Month!<br /> 11-8-2014 :Not in Month!<br /> 11-9-2014 :Not in Month!<br /> 11-11-2014 :Not in Month!<br /> 11-24-2014 :Not in Month!<br /> 11-1-2014 :Not in Month!<br /> 10-30-2014 :Not in Month!<br /> 12-1-2014 :Not in Month!<br /> 11-1-1997 :Not in Month!<br />

preferences:
268.49 ms | 402 KiB | 458 Q