php.net |  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
Votes:1
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me at sebastian-bechtel dot info
New email:
PHP Version: OS:

 

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

Test script:
---------------
<?php                                                                                                                 
$dt = new DateTime('first day of this month');                                                                        
                                                                                                                      
// correct output: "2011-04-01 22:41:17"                                                                                                   
var_dump($dt);                                                                                                        
                
// 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')));


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-20 23:33 UTC] dtajchreber@php.net
-Status: Open +Status: Verified
 [2011-04-20 23:33 UTC] dtajchreber@php.net
Looks related to #54340.
 [2011-04-20 23:36 UTC] derick@php.net
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: derick
 [2011-04-20 23:37 UTC] dtajchreber@php.net
-Status: Assigned +Status: Closed
 [2011-04-20 23:37 UTC] dtajchreber@php.net
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
http://snaps.php.net/.
 
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: Thu Apr 18 06:01:28 2024 UTC