3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $years = 5; $baseDate = new \DateTime(); $baseDate = new \DateTime($baseDate->format('Y-m-01 00:00:00')); $baseDate->modify('-' . $years . ' years'); var_dump($baseDate);
Output for 5.6.0 - 7.3.1
object(DateTime)#2 (3) { ["date"]=> string(26) "2011-09-01 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }