Bug #80610 [NEW]: DateTime calculate wrong with DateInterval

From: Date: Sat, 09 Jan 2021 21:42:45 +0000
Subject: Bug #80610 [NEW]: DateTime calculate wrong with DateInterval
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231469@lists.php.net to get a copy of this message
From: info at mobger dot de Operating system: Docker / PHPSandbox? PHP version: 7.4.14 Package: *Calendar problems Bug Type: Bug Bug description:DateTime calculate wrong with DateInterval Description: ------------ I want to add and sub some minutes fram a date. I use the dateInterval for the calculation. It seems to work with lower numbers of minutes. I have not tested it systemattically. If I üpersonally use PHP 7.4 in my local development (ddev/docker). But I Can repoduce the bug online https://sandbox.onlinephpfunctions.com/ with various php-versions. 8.0.0, 7.4.13, 7.3.25, 7.2.31, 7.1.33, 7.0.14 and 5.6.29. Test script: --------------- <?php //Enter your code here, enjoy! $expectEaster = date_create_from_format('Y-m-d H:i:s', '2020-04-12 12:00:00', new DateTimeZone('Europe/Berlin')); $interval = new DateInterval('PT20800M'); $expectEaster->sub($interval); $expectEaster->add($interval); echo('easter '.$expectEaster->format('Y-m-d H:i:s')."\n" ); $expectEaster = date_create_from_format('Y-m-d H:i:s', '2020-04-12 12:00:00', new DateTimeZone('Europe/Berlin')); $interval = new DateInterval('PT20715M'); $expectEaster->sub($interval); $expectEaster->add($interval); echo('easter '.$expectEaster->format('Y-m-d H:i:s')."\n"); $expectEaster = date_create_from_format('Y-m-d H:i:s', '2020-04-12 12:00:00', new DateTimeZone('Europe/Berlin')); $interval = new DateInterval('PT20700M'); $expectEaster->sub($interval); $expectEaster->add($interval); echo('easter '.$expectEaster->format('Y-m-d H:i:s')."\n"); // Result // easter 2020-04-12 11:00:00 // easter 2020-04-12 13:00:00 // easter 2020-04-12 12:00:00 Expected result: ---------------- easter 2020-04-12 12:00:00 Actual result: -------------- 'PT20800M': easter 2020-04-12 11:00:00 'PT20715M': easter 2020-04-12 13:00:00 'PT20700M': easter 2020-04-12 12:00:00 -- Edit bug report at https://bugs.php.net/bug.php?id=80610&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80610&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80610&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80610&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80610&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80610&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80610&r=support Expected behavior: https://bugs.php.net/fix.php?id=80610&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80610&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80610&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80610&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80610&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80610&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80610&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80610&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80610&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80610&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80610&r=mysqlcfg

« previous php.bugs (#231469) next »