Bug #81458 [NEW]: Regression in PHP 8.1: Incorrect difference after timezone change
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)
- kylekatarnls at gmail dot com
- antonino dot spampinato86 at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- antonino dot spampinato86 at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- kylekatarnls at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- antonino dot spampinato86 at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- kylekatarnls at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- antonino dot spampinato86 at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- alec at alec dot plBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- cmb@php.netBug #81458 [PATCH]: Regression in PHP 8.1: Incorrect difference after timezone change
- cmb@php.netBug #81458 [Opn]: Regression in PHP 8.1: Incorrect difference after timezone change
- antonino dot spampinato86 at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- antonino dot spampinato86 at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- antonino dot spampinato86 at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- kylekatarnls at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- natasa dot cyrus at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- derick@php.netBug #81458 [Asn]: Regression in PHP 8.1: Incorrect difference after timezone change
- kylekatarnls at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- derick@php.netBug #81458 [Asn]: Regression in PHP 8.1: Incorrect difference after timezone change
- git@php.netBug #81458 [Asn->Csd]: Regression in PHP 8.1: Incorrect difference after timezone change
- kylekatarnls at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change
- derick@php.netBug #81458 [Csd]: Regression in PHP 8.1: Incorrect difference after timezone change
- ayanozturk at gmail dot comBug #81458 [Com]: Regression in PHP 8.1: Incorrect difference after timezone change