[php-src] Issue #20967: DateTime[Immutable]::createFromTimestamp(float) misses support for 64bit integers or 32bit environments

From: Date: Sun, 18 Jan 2026 16:03:46 +0000
Subject: [php-src] Issue #20967: DateTime[Immutable]::createFromTimestamp(float) misses support for 64bit integers or 32bit environments
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251564@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20967 Author: marc-mabe ### Description The following code: ```php <?php $dt = DateTime::createFromFormat('U', '2147483647'); var_dump($dt); $dt = $dt->modify('+1 second'); var_dump($dt); $ts = $dt->format('U'); $tsf = (float)$ts; var_dump($ts, $tsf); $dt2 = DateTime::createFromTimestamp($tsf); ``` Resulted in this output: ``` object(DateTime)#1 (3) { ["date"]=> string(26) "2038-01-19 03:14:07.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTime)#1 (3) { ["date"]=> string(26) "2038-01-19 03:14:08.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } string(10) "2147483648" float(2147483648) Fatal error: Uncaught DateRangeError: DateTime::createFromTimestamp(): Argument #1 ($timestamp) must be a finite number between -2147483648 and 2147483647.999999, 2.14748e+9 given ``` But I expected this output instead: ``` object(DateTime)#1 (3) { ["date"]=> string(26) "2038-01-19 03:14:07.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } object(DateTime)#1 (3) { ["date"]=> string(26) "2038-01-19 03:14:08.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } string(10) "2147483648" float(2147483648) object(DateTime)#2 (3) { ["date"]=> string(26) "2038-01-19 03:14:08.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } ``` ### PHP Version ```plain >= PHP 8.4 ``` ### Operating System 32bit environment

« previous php.bugs (#251564) next »