3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $t=date('Y'); $q = date('m'); for($e=$q;$e<=($q+2);$e++){ $ren = $t.'-'. sprintf("%'.02d", $e); var_dump($ren); } $begin = new DateTime( '2016-01-11' ); $numMonths = 3; for($i=0; $i<$numMonths; $i++) { var_dump($begin->modify( '+1 month' )->format("Y-m-d")); }
based on spSEc
Output for 5.5.0 - 7.3.1
string(7) "2016-01" string(7) "2016-02" string(7) "2016-03" string(10) "2016-02-11" string(10) "2016-03-11" string(10) "2016-04-11"