3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php //get First day of Month //get Last day of Month $first_day_of_month = strtotime(date('m-01-Y')); $last_day_of_month = strtotime(date('m-t-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('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 $datetesta) { $comp_date = strtotime($datetesta); if (($comp_date >= $first_day_of_month) && ($comp_date <= $last_day_of_month)){ echo "$comp_date :"; echo " Is in Month!"; echo "<br />\n"; } else { echo "$comp_date :"; echo "Not in Month!"; echo "<br />\n"; } }
based on 14Uoi
Output for 5.1.3 - 7.3.0rc4
First Day of Month: 1389394800<br />Last Day of Month: <br /><br /> :Not in Month!<br /> :Not in Month!<br /> 1407708000 :Not in Month!<br /> 1407708000 :Not in Month!<br /> 1410386400 :Not in Month!<br /> 1415660400 :Not in Month!<br /> :Not in Month!<br /> 1389394800 :Not in Month!<br /> :Not in Month!<br /> 1389481200 :Not in Month!<br /> 852937200 :Not in Month!<br />
Output for 5.1.0 - 5.1.2
First Day of Month: <br />Last Day of Month: <br /><br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br /> : Is in Month!<br />
Output for 4.3.0 - 5.0.5
First Day of Month: 1467756000<br />Last Day of Month: 1543964400<br /><br /> 1543964400 : Is in Month!<br /> 1546556400 :Not in Month!<br /> 1486076400 : Is in Month!<br /> 1486076400 : Is in Month!<br /> 1488754800 : Is in Month!<br /> 1494021600 : Is in Month!<br /> 1528236000 : Is in Month!<br /> 1467756000 : Is in Month!<br /> 1512428400 : Is in Month!<br /> 1499292000 : Is in Month!<br /> 1466287200 :Not in Month!<br />