3v4l.org

run code in 300+ PHP versions simultaneously
<?php // @see https://stackoverflow.com/questions/77131068/how-to-retain-the-time-zone-info-when-truncating-a-timestamp-with-time-zone date_default_timezone_set('UTC'); $dates = [ '1999-12-31 20:59:59+00', '1999-12-31 20:59:59', '2000-01-01 07:29:59', '1999-12-31 20:00:00+00', '1999-12-31 20:00:00', '2000-01-01 07:00:00', '2000-01-01 07:00:00 +00', '2000-01-01 07:00:00 Australia/Adelaide' ]; foreach ($dates as $dateString) { $date = new \DateTimeImmutable($dateString); echo $dateString."\n-> ".$date->format('r')."\n\n"; }
Output for 8.1.23 - 8.1.33, 8.2.10 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
1999-12-31 20:59:59+00 -> Fri, 31 Dec 1999 20:59:59 +0000 1999-12-31 20:59:59 -> Fri, 31 Dec 1999 20:59:59 +0000 2000-01-01 07:29:59 -> Sat, 01 Jan 2000 07:29:59 +0000 1999-12-31 20:00:00+00 -> Fri, 31 Dec 1999 20:00:00 +0000 1999-12-31 20:00:00 -> Fri, 31 Dec 1999 20:00:00 +0000 2000-01-01 07:00:00 -> Sat, 01 Jan 2000 07:00:00 +0000 2000-01-01 07:00:00 +00 -> Sat, 01 Jan 2000 07:00:00 +0000 2000-01-01 07:00:00 Australia/Adelaide -> Sat, 01 Jan 2000 07:00:00 +1030
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
93.51 ms | 408 KiB | 5 Q