3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dt_inicio = new DateTime(); $dt_inicio->setTimestamp(mktime(0,0,0, 6,20,2014)); $dt_fim = new DateTime(); $dt_fim->setTimestamp(mktime(0,0,0, 7,19,2015)); $interval = new DateInterval('P1M'); var_dump($interval); $diffAno = 2015 - 2014; $nmeses = (7 + ($diffAno * 12)) - 6; $period = new DatePeriod($dt_inicio, $interval, $nmeses); foreach($period as $date){ $meses[] = array( "mes"=>$date->format('m'), "ano"=>$date->format('Y') ); } var_dump($meses);
Output for git.master, git.master_jit, rfc.property-hooks
object(DateInterval)#3 (10) { ["y"]=> int(0) ["m"]=> int(1) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["invert"]=> int(0) ["days"]=> bool(false) ["from_string"]=> bool(false) } array(14) { [0]=> array(2) { ["mes"]=> string(2) "06" ["ano"]=> string(4) "2014" } [1]=> array(2) { ["mes"]=> string(2) "07" ["ano"]=> string(4) "2014" } [2]=> array(2) { ["mes"]=> string(2) "08" ["ano"]=> string(4) "2014" } [3]=> array(2) { ["mes"]=> string(2) "09" ["ano"]=> string(4) "2014" } [4]=> array(2) { ["mes"]=> string(2) "10" ["ano"]=> string(4) "2014" } [5]=> array(2) { ["mes"]=> string(2) "11" ["ano"]=> string(4) "2014" } [6]=> array(2) { ["mes"]=> string(2) "12" ["ano"]=> string(4) "2014" } [7]=> array(2) { ["mes"]=> string(2) "01" ["ano"]=> string(4) "2015" } [8]=> array(2) { ["mes"]=> string(2) "02" ["ano"]=> string(4) "2015" } [9]=> array(2) { ["mes"]=> string(2) "03" ["ano"]=> string(4) "2015" } [10]=> array(2) { ["mes"]=> string(2) "04" ["ano"]=> string(4) "2015" } [11]=> array(2) { ["mes"]=> string(2) "05" ["ano"]=> string(4) "2015" } [12]=> array(2) { ["mes"]=> string(2) "06" ["ano"]=> string(4) "2015" } [13]=> array(2) { ["mes"]=> string(2) "07" ["ano"]=> string(4) "2015" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54.01 ms | 405 KiB | 8 Q