date->diff error php 8.1

[email protected] (John Belli)
Newsgroups php.general
Message-ID <DM6PR18MB3433595CFC4CAD32CBAD57A398A59@DM6PR18MB3433.namprd18.prod.outlook.com>
Trying to figure out why my sessions were expiring immediatly on php 8.1 but not 8.0, I found the following:
code fragment:
    $foo = new DateTime();
    $bar = new DateTime($_SESSION['ts']);
    var_dump($foo);
    var_dump($bar);
    $diff = $foo->diff($bar, true);
    var_dump ($diff);

php 8.0:
object(DateTime)#2 (3) {
  ["date"]=>
  string(26) "2022-06-07 18:33:01.543434"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(10) "US/Eastern"
}
object(DateTime)#3 (3) {
  ["date"]=>
  string(26) "2022-06-07 18:32:58.651232"
  ["timezone_type"]=>
  int(1)
  ["timezone"]=>
  string(6) "-04:00"
}
object(DateInterval)#4 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(0)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(2)
  ["f"]=>
  float(0.89220200000000005)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  int(0)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}

php 8.1:
object(DateTime)#2 (3) {
  ["date"]=>
  string(26) "2022-06-07 18:31:30.428703"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(10) "US/Eastern"
}
object(DateTime)#3 (3) {
  ["date"]=>
  string(26) "2022-06-07 18:31:27.274847"
  ["timezone_type"]=>
  int(1)
  ["timezone"]=>
  string(6) "-04:00"
}
object(DateInterval)#4 (16) {
  ["y"]=>
  int(-1)
  ["m"]=>
  int(11)
  ["d"]=>
  int(29)
  ["h"]=>
  int(23)
  ["i"]=>
  int(0)
  ["s"]=>
  int(3)
  ["f"]=>
  float(0.15385599999999999)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  int(0)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}

What is happening here? Am I doing something wrong that just happened to accidentally work from 5.6-8.0, or did I find a bug?


JAB
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.