3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getQuarterEndingOf($month) { $quarterEndings = [ 1 => 'Mar', 2 => 'Mar', 3 => 'Mar', 4 => 'Jun', 5 => 'Jun', 6 => 'Jun', 7 => 'Sep', 8 => 'Sep', 9 => 'Sep', 10 => 'Dec', 11 => 'Dec', 12 => 'Dec', ]; $timeFormat = sprintf('%s %s', $quarterEndings[$month], date('Y') ); return new \DateTime($timeFormat); } var_dump(getQuarterEndingOf(11)); $d = new \DateTime(); var_dump(var_dump($d->setDate(date('Y'), floor(date('m')/3),date('m'))));
based on SRuDr
Output for 7.1.2, 7.3.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000195" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.3.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000188" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000223" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000204" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000225" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.18, 7.2.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000216" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000210" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000367" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000302" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000189" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000199" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000401" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000200" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000226" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000231" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.2.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000212" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000222" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000319" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.23
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000356" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.22
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000339" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000248" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000265" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000203" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000205" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000206" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000227" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000193" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000393" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000213" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000286" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000256" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000245" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000207" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000300" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000214" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000187" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000208" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 5.4.30 - 5.4.45, 5.5.14 - 7.0.33, 7.1.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 7.1.0 - 7.1.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(26) "2015-03-09 04:46:41.000253" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 5.4.0 - 5.4.29, 5.5.0 - 5.5.13
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-12-01 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#1 (3) { ["date"]=> string(19) "2015-03-09 04:46:41" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } NULL
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/LuZ9H on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/LuZ9H on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/LuZ9H on line 5
Process exited with code 255.