3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $start = new \DateTime('1st January'); $end = new \DateTime('31st December'); $interval = new \DateInterval('P1D'); $period = new \DatePeriod($start, $interval, $end->modify('+ 1 day')); $year = array(); foreach($period as $day){ $year[$day->format('M')][(int)$day->format('d')] = $day->format('D'); } var_dump($year);
Output for 5.3.0 - 7.1.0
array(12) { ["Jan"]=> array(31) { [1]=> string(3) "Tue" [2]=> string(3) "Wed" [3]=> string(3) "Thu" [4]=> string(3) "Fri" [5]=> string(3) "Sat" [6]=> string(3) "Sun" [7]=> string(3) "Mon" [8]=> string(3) "Tue" [9]=> string(3) "Wed" [10]=> string(3) "Thu" [11]=> string(3) "Fri" [12]=> string(3) "Sat" [13]=> string(3) "Sun" [14]=> string(3) "Mon" [15]=> string(3) "Tue" [16]=> string(3) "Wed" [17]=> string(3) "Thu" [18]=> string(3) "Fri" [19]=> string(3) "Sat" [20]=> string(3) "Sun" [21]=> string(3) "Mon" [22]=> string(3) "Tue" [23]=> string(3) "Wed" [24]=> string(3) "Thu" [25]=> string(3) "Fri" [26]=> string(3) "Sat" [27]=> string(3) "Sun" [28]=> string(3) "Mon" [29]=> string(3) "Tue" [30]=> string(3) "Wed" [31]=> string(3) "Thu" } ["Feb"]=> array(28) { [1]=> string(3) "Fri" [2]=> string(3) "Sat" [3]=> string(3) "Sun" [4]=> string(3) "Mon" [5]=> string(3) "Tue" [6]=> string(3) "Wed" [7]=> string(3) "Thu" [8]=> string(3) "Fri" [9]=> string(3) "Sat" [10]=> string(3) "Sun" [11]=> string(3) "Mon" [12]=> string(3) "Tue" [13]=> string(3) "Wed" [14]=> string(3) "Thu" [15]=> string(3) "Fri" [16]=> string(3) "Sat" [17]=> string(3) "Sun" [18]=> string(3) "Mon" [19]=> string(3) "Tue" [20]=> string(3) "Wed" [21]=> string(3) "Thu" [22]=> string(3) "Fri" [23]=> string(3) "Sat" [24]=> string(3) "Sun" [25]=> string(3) "Mon" [26]=> string(3) "Tue" [27]=> string(3) "Wed" [28]=> string(3) "Thu" } ["Mar"]=> array(31) { [1]=> string(3) "Fri" [2]=> string(3) "Sat" [3]=> string(3) "Sun" [4]=> string(3) "Mon" [5]=> string(3) "Tue" [6]=> string(3) "Wed" [7]=> string(3) "Thu" [8]=> string(3) "Fri" [9]=> string(3) "Sat" [10]=> string(3) "Sun" [11]=> string(3) "Mon" [12]=> string(3) "Tue" [13]=> string(3) "Wed" [14]=> string(3) "Thu" [15]=> string(3) "Fri" [16]=> string(3) "Sat" [17]=> string(3) "Sun" [18]=> string(3) "Mon" [19]=> string(3) "Tue" [20]=> string(3) "Wed" [21]=> string(3) "Thu" [22]=> string(3) "Fri" [23]=> string(3) "Sat" [24]=> string(3) "Sun" [25]=> string(3) "Mon" [26]=> string(3) "Tue" [27]=> string(3) "Wed" [28]=> string(3) "Thu" [29]=> string(3) "Fri" [30]=> string(3) "Sat" [31]=> string(3) "Sun" } ["Apr"]=> array(30) { [1]=> string(3) "Mon" [2]=> string(3) "Tue" [3]=> string(3) "Wed" [4]=> string(3) "Thu" [5]=> string(3) "Fri" [6]=> string(3) "Sat" [7]=> string(3) "Sun" [8]=> string(3) "Mon" [9]=> string(3) "Tue" [10]=> string(3) "Wed" [11]=> string(3) "Thu" [12]=> string(3) "Fri" [13]=> string(3) "Sat" [14]=> string(3) "Sun" [15]=> string(3) "Mon" [16]=> string(3) "Tue" [17]=> string(3) "Wed" [18]=> string(3) "Thu" [19]=> string(3) "Fri" [20]=> string(3) "Sat" [21]=> string(3) "Sun" [22]=> string(3) "Mon" [23]=> string(3) "Tue" [24]=> string(3) "Wed" [25]=> string(3) "Thu" [26]=> string(3) "Fri" [27]=> string(3) "Sat" [28]=> string(3) "Sun" [29]=> string(3) "Mon" [30]=> string(3) "Tue" } ["May"]=> array(31) { [1]=> string(3) "Wed" [2]=> string(3) "Thu" [3]=> string(3) "Fri" [4]=> string(3) "Sat" [5]=> string(3) "Sun" [6]=> string(3) "Mon" [7]=> string(3) "Tue" [8]=> string(3) "Wed" [9]=> string(3) "Thu" [10]=> string(3) "Fri" [11]=> string(3) "Sat" [12]=> string(3) "Sun" [13]=> string(3) "Mon" [14]=> string(3) "Tue" [15]=> string(3) "Wed" [16]=> string(3) "Thu" [17]=> string(3) "Fri" [18]=> string(3) "Sat" [19]=> string(3) "Sun" [20]=> string(3) "Mon" [21]=> string(3) "Tue" [22]=> string(3) "Wed" [23]=> string(3) "Thu" [24]=> string(3) "Fri" [25]=> string(3) "Sat" [26]=> string(3) "Sun" [27]=> string(3) "Mon" [28]=> string(3) "Tue" [29]=> string(3) "Wed" [30]=> string(3) "Thu" [31]=> string(3) "Fri" } ["Jun"]=> array(30) { [1]=> string(3) "Sat" [2]=> string(3) "Sun" [3]=> string(3) "Mon" [4]=> string(3) "Tue" [5]=> string(3) "Wed" [6]=> string(3) "Thu" [7]=> string(3) "Fri" [8]=> string(3) "Sat" [9]=> string(3) "Sun" [10]=> string(3) "Mon" [11]=> string(3) "Tue" [12]=> string(3) "Wed" [13]=> string(3) "Thu" [14]=> string(3) "Fri" [15]=> string(3) "Sat" [16]=> string(3) "Sun" [17]=> string(3) "Mon" [18]=> string(3) "Tue" [19]=> string(3) "Wed" [20]=> string(3) "Thu" [21]=> string(3) "Fri" [22]=> string(3) "Sat" [23]=> string(3) "Sun" [24]=> string(3) "Mon" [25]=> string(3) "Tue" [26]=> string(3) "Wed" [27]=> string(3) "Thu" [28]=> string(3) "Fri" [29]=> string(3) "Sat" [30]=> string(3) "Sun" } ["Jul"]=> array(31) { [1]=> string(3) "Mon" [2]=> string(3) "Tue" [3]=> string(3) "Wed" [4]=> string(3) "Thu" [5]=> string(3) "Fri" [6]=> string(3) "Sat" [7]=> string(3) "Sun" [8]=> string(3) "Mon" [9]=> string(3) "Tue" [10]=> string(3) "Wed" [11]=> string(3) "Thu" [12]=> string(3) "Fri" [13]=> string(3) "Sat" [14]=> string(3) "Sun" [15]=> string(3) "Mon" [16]=> string(3) "Tue" [17]=> string(3) "Wed" [18]=> string(3) "Thu" [19]=> string(3) "Fri" [20]=> string(3) "Sat" [21]=> string(3) "Sun" [22]=> string(3) "Mon" [23]=> string(3) "Tue" [24]=> string(3) "Wed" [25]=> string(3) "Thu" [26]=> string(3) "Fri" [27]=> string(3) "Sat" [28]=> string(3) "Sun" [29]=> string(3) "Mon" [30]=> string(3) "Tue" [31]=> string(3) "Wed" } ["Aug"]=> array(31) { [1]=> string(3) "Thu" [2]=> string(3) "Fri" [3]=> string(3) "Sat" [4]=> string(3) "Sun" [5]=> string(3) "Mon" [6]=> string(3) "Tue" [7]=> string(3) "Wed" [8]=> string(3) "Thu" [9]=> string(3) "Fri" [10]=> string(3) "Sat" [11]=> string(3) "Sun" [12]=> string(3) "Mon" [13]=> string(3) "Tue" [14]=> string(3) "Wed" [15]=> string(3) "Thu" [16]=> string(3) "Fri" [17]=> string(3) "Sat" [18]=> string(3) "Sun" [19]=> string(3) "Mon" [20]=> string(3) "Tue" [21]=> string(3) "Wed" [22]=> string(3) "Thu" [23]=> string(3) "Fri" [24]=> string(3) "Sat" [25]=> string(3) "Sun" [26]=> string(3) "Mon" [27]=> string(3) "Tue" [28]=> string(3) "Wed" [29]=> string(3) "Thu" [30]=> string(3) "Fri" [31]=> string(3) "Sat" } ["Sep"]=> array(30) { [1]=> string(3) "Sun" [2]=> string(3) "Mon" [3]=> string(3) "Tue" [4]=> string(3) "Wed" [5]=> string(3) "Thu" [6]=> string(3) "Fri" [7]=> string(3) "Sat" [8]=> string(3) "Sun" [9]=> string(3) "Mon" [10]=> string(3) "Tue" [11]=> string(3) "Wed" [12]=> string(3) "Thu" [13]=> string(3) "Fri" [14]=> string(3) "Sat" [15]=> string(3) "Sun" [16]=> string(3) "Mon" [17]=> string(3) "Tue" [18]=> string(3) "Wed" [19]=> string(3) "Thu" [20]=> string(3) "Fri" [21]=> string(3) "Sat" [22]=> string(3) "Sun" [23]=> string(3) "Mon" [24]=> string(3) "Tue" [25]=> string(3) "Wed" [26]=> string(3) "Thu" [27]=> string(3) "Fri" [28]=> string(3) "Sat" [29]=> string(3) "Sun" [30]=> string(3) "Mon" } ["Oct"]=> array(31) { [1]=> string(3) "Tue" [2]=> string(3) "Wed" [3]=> string(3) "Thu" [4]=> string(3) "Fri" [5]=> string(3) "Sat" [6]=> string(3) "Sun" [7]=> string(3) "Mon" [8]=> string(3) "Tue" [9]=> string(3) "Wed" [10]=> string(3) "Thu" [11]=> string(3) "Fri" [12]=> string(3) "Sat" [13]=> string(3) "Sun" [14]=> string(3) "Mon" [15]=> string(3) "Tue" [16]=> string(3) "Wed" [17]=> string(3) "Thu" [18]=> string(3) "Fri" [19]=> string(3) "Sat" [20]=> string(3) "Sun" [21]=> string(3) "Mon" [22]=> string(3) "Tue" [23]=> string(3) "Wed" [24]=> string(3) "Thu" [25]=> string(3) "Fri" [26]=> string(3) "Sat" [27]=> string(3) "Sun" [28]=> string(3) "Mon" [29]=> string(3) "Tue" [30]=> string(3) "Wed" [31]=> string(3) "Thu" } ["Nov"]=> array(30) { [1]=> string(3) "Fri" [2]=> string(3) "Sat" [3]=> string(3) "Sun" [4]=> string(3) "Mon" [5]=> string(3) "Tue" [6]=> string(3) "Wed" [7]=> string(3) "Thu" [8]=> string(3) "Fri" [9]=> string(3) "Sat" [10]=> string(3) "Sun" [11]=> string(3) "Mon" [12]=> string(3) "Tue" [13]=> string(3) "Wed" [14]=> string(3) "Thu" [15]=> string(3) "Fri" [16]=> string(3) "Sat" [17]=> string(3) "Sun" [18]=> string(3) "Mon" [19]=> string(3) "Tue" [20]=> string(3) "Wed" [21]=> string(3) "Thu" [22]=> string(3) "Fri" [23]=> string(3) "Sat" [24]=> string(3) "Sun" [25]=> string(3) "Mon" [26]=> string(3) "Tue" [27]=> string(3) "Wed" [28]=> string(3) "Thu" [29]=> string(3) "Fri" [30]=> string(3) "Sat" } ["Dec"]=> array(31) { [1]=> string(3) "Sun" [2]=> string(3) "Mon" [3]=> string(3) "Tue" [4]=> string(3) "Wed" [5]=> string(3) "Thu" [6]=> string(3) "Fri" [7]=> string(3) "Sat" [8]=> string(3) "Sun" [9]=> string(3) "Mon" [10]=> string(3) "Tue" [11]=> string(3) "Wed" [12]=> string(3) "Thu" [13]=> string(3) "Fri" [14]=> string(3) "Sat" [15]=> string(3) "Sun" [16]=> string(3) "Mon" [17]=> string(3) "Tue" [18]=> string(3) "Wed" [19]=> string(3) "Thu" [20]=> string(3) "Fri" [21]=> string(3) "Sat" [22]=> string(3) "Sun" [23]=> string(3) "Mon" [24]=> string(3) "Tue" [25]=> string(3) "Wed" [26]=> string(3) "Thu" [27]=> string(3) "Fri" [28]=> string(3) "Sat" [29]=> string(3) "Sun" [30]=> string(3) "Mon" [31]=> string(3) "Tue" } }
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 5 Fatal error: Class 'DateInterval' not found in /in/UYTND on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 5 Fatal error: Class 'DateTime' not found in /in/UYTND on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 5 Fatal error: Cannot instantiate non-existent class: datetime in /in/UYTND on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 4 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/UYTND on line 5 Fatal error: Cannot instantiate non-existent class: datetime in /in/UYTND on line 2