|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53067 DateTime::add && DateTime::sub changes original dateTime object
Submitted: 2010-10-14 15:31 UTC Modified: 2010-10-14 23:28 UTC
From: bogunov at gmail dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.3.2 OS: Windows
Private report: No CVE-ID: None
 [2010-10-14 15:31 UTC] bogunov at gmail dot com
Documentation says it should return new Object thought it returns modified old.

PHP 5.3.2 (cli) (built: Mar  3 2010 20:36:54)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

Test script:
$day_interval = new DateInterval('P1D');
$cur_date = new DateTime('2000-01-02');
echo $cur_date->add($day_interval)->format('Y-m-d');
echo $cur_date->sub($day_interval)->format('Y-m-d');

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-14 15:32 UTC] bogunov at gmail dot com
-PHP Version: 5.3.3 +PHP Version: 5.3.2
 [2010-10-14 15:32 UTC] bogunov at gmail dot com
5.3.2 version instead of 5.3.3 as selected first time
 [2010-10-14 16:09 UTC]
-Status: Open +Status: Feedback -Type: Bug +Type: Documentation Problem
 [2010-10-14 16:09 UTC]
The documentation states that those methods return "the modified DateTime object 
or FALSE on failure."  Could you provide a link to where the docs say that a new 
object is returned?
 [2010-10-14 23:28 UTC] bogunov at gmail dot com
-Status: Feedback +Status: Closed
 [2010-10-14 23:28 UTC] bogunov at gmail dot com
ok, sorry, my mistake, misunderstood the documentation. Thought "modified DateTime 
object" means "new".
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC