3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $needYear=2018; $needMonth=10; $_startTime = strtotime('2018-10-31 00:00:00'); $_endTime = strtotime('2018-11-01 00:00:00'); var_dump(date('Y-n', $_startTime), date('Y-n', $_endTime), $needYear . '-' . $needMonth); var_dump(date('Y-m-d', strtotime('last day of' . $needYear . '-' . $needMonth)));
based on 3d1NS
Output for 5.6.38 - 7.3.0rc3
string(7) "2018-10" string(7) "2018-11" string(7) "2018-10" string(10) "2018-10-31"