-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Labels
Description
Description
The following code:
<?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
>= PHP 8.4
Operating System
32bit environment