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 = mktime(0,0,0); $last_day_of_month = mktime(23,59,59,date('n'),date('j'),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('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); print_r($split_date); $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 "$comp_date :"; echo " Is in Month!"; echo "<br />\n"; } else { echo "$comp_date :"; echo "Not in Month!"; echo "<br />\n"; } }
based on OvTi1
Output for 4.3.0 - 7.3.0beta1
First Day of Month: 1415055600<br />Last Day of Month: 1415141999<br /><br /> Array ( [0] => 11 [1] => 30 [2] => 2014 ) 1417302000 :Not in Month!<br /> Array ( [0] => 11 [1] => 31 [2] => 2014 ) 1417388400 :Not in Month!<br /> Array ( [0] => 11 [1] => 08 [2] => 2014 ) 1415401200 :Not in Month!<br /> Array ( [0] => 11 [1] => 8 [2] => 2014 ) 1415401200 :Not in Month!<br /> Array ( [0] => 11 [1] => 9 [2] => 2014 ) 1415487600 :Not in Month!<br /> Array ( [0] => 11 [1] => 11 [2] => 2014 ) 1415660400 :Not in Month!<br /> Array ( [0] => 11 [1] => 24 [2] => 2014 ) 1416783600 :Not in Month!<br /> Array ( [0] => 11 [1] => 1 [2] => 2014 ) 1414796400 :Not in Month!<br /> Array ( [0] => 10 [1] => 30 [2] => 2014 ) 1414623600 :Not in Month!<br /> Array ( [0] => 12 [1] => 1 [2] => 2014 ) 1417388400 :Not in Month!<br /> Array ( [0] => 11 [1] => 1 [2] => 1997 ) 878338800 :Not in Month!<br />