Skip to content

Different diff->days between php 8.0.28 and php 8.1  #10822

@szpakucjusz

Description

@szpakucjusz

Description

Good morning,
Link with different php versions comparison: https://3v4l.org/mgOoE#v8.1.0
The following code returns the difference for DateInterval->days:

<?php 
$d = new DateTime('-1 day');
$diff = $d->diff(new DateTime('-6 days') );
echo "\n";
print_r($diff);
echo $diff->days;
echo "\n";

Resulted in this output for php 8.0.28:

DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 4
    [h] => 23
    [i] => 59
    [s] => 59
    [f] => 0.999994
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 1
    [days] => 5
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)

But In PHP 8.1.0:

DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 4
    [h] => 23
    [i] => 59
    [s] => 59
    [f] => 0.99999
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 1
    [days] => 4
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)

PHP Version

Change between PHP 8.0.28 and 8.1

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions