|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54579 DateTime sub problem
Submitted: 2011-04-20 22:44 UTC Modified: 2011-04-20 23:37 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: me at sebastian-bechtel dot info Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.6 OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: me at sebastian-bechtel dot info
New email:
PHP Version: OS:


 [2011-04-20 22:44 UTC] me at sebastian-bechtel dot info
DateTime::sub() does not work on objects created by a date string. If the object 
is created by timestamp it works.

Test script:
$dt = new DateTime('first day of this month');                                                                        
// correct output: "2011-04-01 22:41:17"                                                                                                   
// wrong output: "2011-04-01 22:41:17"                                                                                             
var_dump($dt->sub(new DateInterval('P2D')));                                                                          
// correct output: "2011-03-30 20:41:17"                                                                                       
var_dump(date_create('@' . $dt->getTimestamp())->sub(new DateInterval('P2D')));


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-20 23:33 UTC]
-Status: Open +Status: Verified
 [2011-04-20 23:33 UTC]
Looks related to #54340.
 [2011-04-20 23:36 UTC]
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: derick
 [2011-04-20 23:37 UTC]
-Status: Assigned +Status: Closed
 [2011-04-20 23:37 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

And it is indeed fixed in snapshots.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Mar 04 11:01:28 2024 UTC