|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-02-02 18:04 UTC] charlesb at itsmystuff dot com
Description:
------------
Each time DateTime::getTimestamp is called, a previously called DateTime::sub value is applied. This does not occur with DateTime::add.
Reproduce code:
---------------
$work_time = new DateTime("2010-01-30 12:00:00");
$work_time->sub(new DateInterval("P7D"));
$window_start = $work_time->getTimestamp();
echo date("Y-m-d H:i:s", $window_start) . "<br />";
$window_start = $work_time->getTimestamp();
echo date("Y-m-d H:i:s", $window_start) . "<br />";
Expected result:
----------------
2010-01-23 12:00:00
2010-01-23 12:00:00
Actual result:
--------------
2010-01-16 12:00:00
2010-01-09 12:00:00
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 01:00:01 2025 UTC |
This bug is confirmed to still be alive in snapshot "5.3-201002200930" compiled on Debian Linux. Reproduction code: $Time = new \DateTime('NOW'); $Month = new \DateInterval('P1Y'); var_dump($Time); // Correctly subtracted $Time->sub($Month); var_dump($Time); // Wrongly subtracted $Time->getTimestamp(); var_dump($Time);