Bug #81458 [NEW]: Regression in PHP 8.1: Incorrect difference after timezone change

From: Date: Sat, 18 Sep 2021 19:56:21 +0000
Subject: Bug #81458 [NEW]: Regression in PHP 8.1: Incorrect difference after timezone change
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236677@lists.php.net to get a copy of this message
From:             kylekatarnls at gmail dot com
Operating system: 
PHP version:      8.1Git-2021-09-18 (Git)
Package:          Date/time related
Bug Type:         Bug
Bug description:Regression in PHP 8.1: Incorrect difference after timezone change

Description:
------------
In PHP 8.0 diff()->days returned the total number of days between dates
even if one of them were in UTC and not the other

In PHP 8.1 (since beta3 I think) ->d is still OK but ->days is now 0

Test script:
---------------
<?php

$first = (new DateTime('2018-07-01 00:00:00.000000 America/Toronto'))
    ->setTimezone(new DateTimeZone('UTC'));
$second = new DateTime('2018-07-02 00:00:00.000000 America/Toronto');

var_dump($first->diff($second)->days);
var_dump($first->diff($second)->d);


Expected result:
----------------
int(1)
int(1)

Actual result:
--------------
int(0)
int(1)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=81458&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81458&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81458&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81458&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81458&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81458&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81458&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81458&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81458&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81458&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81458&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81458&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81458&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81458&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81458&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81458&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81458&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81458&r=mysqlcfg


Thread (22 messages)

« previous php.bugs (#236677) next »