Bug #81263 [Opn->Dup]: Wrong result from DateTimeImmutable::diff

From: Date: Sun, 08 Aug 2021 11:18:24 +0000
Subject: Bug #81263 [Opn->Dup]: Wrong result from DateTimeImmutable::diff
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235678@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81263&edit=1

 ID:                 81263
 Updated by:         derick@php.net
 Reported by:        mail at gh01 dot de
 Summary:            Wrong result from DateTimeImmutable::diff
-Status:             Open
+Status:             Duplicate
 Type:               Bug
 Package:            Date/time related
 PHP Version:        master-Git-2021-07-15 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

Duplicate of #81273


Previous Comments:
------------------------------------------------------------------------
[2021-07-15 21:32:41] mail at gh01 dot de

Description:
------------
PHP 8.0 (correct): https://3v4l.org/Wofuu#v8.0.8
PHP 8.1 (wrong): https://3v4l.org/Wofuu/rfc#vgit.master

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

$dt1 = new DateTimeImmutable('2020-07-19 18:30:00', new
DateTimeZone('Europe/Berlin'));
$dt2 = new DateTimeImmutable('2020-07-19 16:30:00', new DateTimeZone('UTC'));

print_r($dt1->diff($dt2));

Expected result:
----------------
DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 0
    [h] => 0
    [i] => 0
    [s] => 0
    [f] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 0
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)

Actual result:
--------------
DateInterval Object
(
    [y] => -1
    [m] => 11
    [d] => 29
    [h] => 24
    [i] => 0
    [s] => 0
    [f] => 0
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 0
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81263&edit=1


Thread (8 messages)

« previous php.bugs (#235678) next »