3v4l.org

run code in 500+ PHP versions simultaneously
<?php date_default_timezone_set('Europe/London'); $ts = 1635641999; $t = (new \DateTime())->setTimestamp($ts); echo $t->format('r'), "\n"; echo $t->getTimestamp(), "\n"; echo ($ts === $t->getTimestamp() ? 'correct' : 'incorrect'), "\n\n"; $ts++; $t = (new \DateTime())->setTimestamp($ts); echo $t->format('r'), "\n"; echo $t->getTimestamp(), "\n"; echo ($ts === $t->getTimestamp() ? 'correct' : 'incorrect'), "\n\n";
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.6
Sun, 31 Oct 2021 01:59:59 +0000 1635645599 incorrect Sun, 31 Oct 2021 01:00:00 +0000 1635642000 correct
Output for 8.1.7 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
Sun, 31 Oct 2021 01:59:59 +0100 1635641999 correct Sun, 31 Oct 2021 01:00:00 +0000 1635642000 correct

preferences:
28.29 ms | 1140 KiB | 9 Q