3v4l.org

run code in 300+ PHP versions simultaneously
<?php $years = 5; $baseDate = new \DateTime(); $baseDate = new \DateTime($baseDate->format('Y-m-01 00:00:00')); $baseDate->modify('-' . $years . ' years'); var_dump($baseDate);

preferences:
24.44 ms | 404 KiB | 5 Q