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
 [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

Pull Requests

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: Tue Oct 08 18:01:27 2024 UTC