php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bogunov at gmail dot com
New email:
PHP Version: OS:

 

 [2010-10-14 15:31 UTC] bogunov at gmail dot com
Description:
------------
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:
----------------
2000-01-03
2000-01-01

Actual result:
--------------
2000-01-03
2000-01-02

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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] salathe@php.net
-Status: Open +Status: Feedback -Type: Bug +Type: Documentation Problem
 [2010-10-14 16:09 UTC] salathe@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 18:01:28 2024 UTC