| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2021-01-09 21:42 UTC] info at mobger dot de
 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 10:00:02 2025 UTC | 
It seems not to be a bug. I ignored the problem of summertime, which is not really good described in the documentation. $expectEaster = date_create_from_format('Y-m-d H:i:s', '2020-04-12 12:00:00', new DateTimeZone('Europe/Berlin')); $interval = new DateInterval('PT20761M'); $expectEaster->sub($interval); echo('recalc '.$expectEaster->format('Y-m-d H:i:s')."\n"); $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('PT20760M'); $expectEaster->sub($interval); echo('recalc '.$expectEaster->format('Y-m-d H:i:s')."\n"); $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('PT20701M'); $expectEaster->sub($interval); echo('recalc '.$expectEaster->format('Y-m-d H:i:s')."\n"); $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); echo('recalc '.$expectEaster->format('Y-m-d H:i:s')."\n"); $expectEaster->add($interval); echo('easter '.$expectEaster->format('Y-m-d H:i:s')."\n"); // recalc 2020-03-29 00:59:00 // remove the missing hour // easter 2020-04-12 11:00:00 // remove the missing hour a second time via adding // recalc 2020-03-29 03:00:00 // easter 2020-04-12 13:00:00 // recalc 2020-03-29 03:59:00 // easter 2020-04-12 13:00:00 // recalc 2020-03-29 03:00:00 // easter 2020-04-12 12:00:00