Bug #54579 [Opn->Ver]: DateTime sub problem
| From: | dtajchreber@php.net | Date: | Wed, 20 Apr 2011 21:33:48 +0000 |
| Subject: | Bug #54579 [Opn->Ver]: DateTime sub problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-160313@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54579&edit=1
ID: 54579
Updated by: dtajchreber@php.net
Reported by: me at sebastian-bechtel dot info
Summary: DateTime sub problem
-Status: Open
+Status: Verified
Type: Bug
Package: Date/time related
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
Looks related to #54340.
Previous Comments:
------------------------------------------------------------------------
[2011-04-20 22:44:16] 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')));
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54579&edit=1