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))); var_dump(date('Y-m-d', strtotime($needYear . '-' . $needMonth . ' last day'))); var_dump(date('Y-m-d', strtotime('first day of ' . $needYear . '-' . $needMonth))); var_dump(date('Y-m-d', strtotime($needYear . '-' . $needMonth . ' first day')));
based on LA3Dq
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" string(10) "2018-09-30" string(10) "2018-10-01" string(10) "2018-10-02"