3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dateTimeBeforeStr = "2024/09/01 00:00:00"; $dateTimeBefore = new DateTimeImmutable($dateTimeBeforeStr); $dateTimeAfter = $dateTimeBefore->modify("-1 second"); $dateTimeAfterStr = $dateTimeAfter->format('Y-m-d H:i:s'); var_dump($dateTimeBeforeStr); var_dump($dateTimeBefore); var_dump($dateTimeAfter); var_dump($dateTimeAfterStr);

preferences:
24.49 ms | 404 KiB | 5 Q