3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = new DateTime('2010-12-02'); $end = new DateTime('2012-05-06'); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod($start, $interval, $end); foreach ($period as $dt) { $result['year'][] = $dt->format("Y"); $result['month'][] = $dt->format("m"); $result['day'][] = $dt->format("m"); } array_unique($result); print_r($result);
based on voEab
Output for hhvm-3.18.5 - 3.21.3, 7.2.0 - 7.3.0beta1
Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Array ( [year] => Array ( [0] => 2010 [1] => 2011 [2] => 2011 [3] => 2011 [4] => 2011 [5] => 2011 [6] => 2011 [7] => 2011 [8] => 2011 [9] => 2011 [10] => 2011 [11] => 2011 [12] => 2011 [13] => 2012 [14] => 2012 [15] => 2012 [16] => 2012 [17] => 2012 ) [month] => Array ( [0] => 12 [1] => 01 [2] => 02 [3] => 03 [4] => 04 [5] => 05 [6] => 06 [7] => 07 [8] => 08 [9] => 09 [10] => 10 [11] => 11 [12] => 12 [13] => 01 [14] => 02 [15] => 03 [16] => 04 [17] => 05 ) [day] => Array ( [0] => 12 [1] => 01 [2] => 02 [3] => 03 [4] => 04 [5] => 05 [6] => 06 [7] => 07 [8] => 08 [9] => 09 [10] => 10 [11] => 11 [12] => 12 [13] => 01 [14] => 02 [15] => 03 [16] => 04 [17] => 05 ) )
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.20
Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Notice: Array to string conversion in /in/TEQGB on line 13 Array ( [year] => Array ( [0] => 2010 [1] => 2011 [2] => 2011 [3] => 2011 [4] => 2011 [5] => 2011 [6] => 2011 [7] => 2011 [8] => 2011 [9] => 2011 [10] => 2011 [11] => 2011 [12] => 2011 [13] => 2012 [14] => 2012 [15] => 2012 [16] => 2012 [17] => 2012 ) [month] => Array ( [0] => 12 [1] => 01 [2] => 02 [3] => 03 [4] => 04 [5] => 05 [6] => 06 [7] => 07 [8] => 08 [9] => 09 [10] => 10 [11] => 11 [12] => 12 [13] => 01 [14] => 02 [15] => 03 [16] => 04 [17] => 05 ) [day] => Array ( [0] => 12 [1] => 01 [2] => 02 [3] => 03 [4] => 04 [5] => 05 [6] => 06 [7] => 07 [8] => 08 [9] => 09 [10] => 10 [11] => 11 [12] => 12 [13] => 01 [14] => 02 [15] => 03 [16] => 04 [17] => 05 ) )
Output for hhvm-3.22.0
Notice: Array to string conversion in /in/TEQGB on line -1 Notice: Array to string conversion in /in/TEQGB on line -1 Notice: Array to string conversion in /in/TEQGB on line -1 Array ( [year] => Array ( [0] => 2010 [1] => 2011 [2] => 2011 [3] => 2011 [4] => 2011 [5] => 2011 [6] => 2011 [7] => 2011 [8] => 2011 [9] => 2011 [10] => 2011 [11] => 2011 [12] => 2011 [13] => 2012 [14] => 2012 [15] => 2012 [16] => 2012 [17] => 2012 ) [month] => Array ( [0] => 12 [1] => 01 [2] => 02 [3] => 03 [4] => 04 [5] => 05 [6] => 06 [7] => 07 [8] => 08 [9] => 09 [10] => 10 [11] => 11 [12] => 12 [13] => 01 [14] => 02 [15] => 03 [16] => 04 [17] => 05 ) [day] => Array ( [0] => 12 [1] => 01 [2] => 02 [3] => 03 [4] => 04 [5] => 05 [6] => 06 [7] => 07 [8] => 08 [9] => 09 [10] => 10 [11] => 11 [12] => 12 [13] => 01 [14] => 02 [15] => 03 [16] => 04 [17] => 05 ) )