3v4l.org

run code in 300+ PHP versions simultaneously
<?php $currentDate = new DateTimeImmutable(); $firstOfTheMonth = new DateTimeImmutable($currentDate->format('Y-m-1')); var_dump($firstOfTheMonth->modify("-1 month"));

preferences:
30.28 ms | 404 KiB | 5 Q