- Notifications
You must be signed in to change notification settings - Fork8k
Closed
Description
Description
The following code:
foreach ([0.4,0, -0.4, -1, -1.4]as$ts) {$date =newDateTime('@' .$ts);print_r($date);}
Diff of current output vs expected:
DateTime Object ( [date] => 1970-01-01 00:00:00.400000 [timezone_type] => 1 [timezone] => +00:00 ) DateTime Object ( [date] => 1970-01-01 00:00:00.000000 [timezone_type] => 1 [timezone] => +00:00 ) DateTime Object (- [date] => 1970-01-01 00:00:00.400000+ [date] => 1969-12-31 23:59:59.600000 [timezone_type] => 1 [timezone] => +00:00 ) DateTime Object ( [date] => 1969-12-31 23:59:59.000000 [timezone_type] => 1 [timezone] => +00:00 ) DateTime Object (- [date] => 1969-12-31 23:59:59.400000+ [date] => 1969-12-31 23:59:58.600000 [timezone_type] => 1 [timezone] => +00:00 )
PHP Version
present since PHP 8.0, should be fixed starting this version
it seems the issue is present only when TS is parsed,getTimestamp
/format('u')
seems correct across all PHP versions -https://3v4l.org/CjJLf