3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dateTimeStrBefore = "2024/09/01 10:00:00"; $dateTimeBefore = new DateTimeImmutable($dateTimeStrBefore); $dateTimeAfter = $dateTimeBefore->modify("-1 second"); var_dump($dateTimeBefore); var_dump($dateTimeAfter);
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2024-09-01 10:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2024-09-01 09:59:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }

preferences:
42.31 ms | 407 KiB | 5 Q