From:
Operating system: Windows 7 Professional
PHP version: 5.3.3
Package: Date/time related
Bug Type: Bug
Bug description:Relative dates and getTimestamp increments by one day
Description:
------------
If you create a DateTime object using a relative date string of "this week
+6 days", when calling getTimestamp on the datetime object, the date is
mysteriously increments by one day. However, if you seperately modify the
datetime using 'this week', then '+6 days', it works correctly.
Where is the additional day comeing from, and why is it only applied when
calling format('U') DOESNT increment the datetime by 1 day. Wierd!
Here is a work around:
$endOfWeek = new DateTime();
$endOfWeek->modify('this week');
$endOfWeek->modify('+6 days');
echo $endOfWeek->format('Y-m-d H:m:s')."\n";
echo $endOfWeek->format('U')."\n";
/* Thar she blows! */
echo $endOfWeek->getTimestamp()."\n";
echo $endOfWeek->format('Y-m-d H:m:s')."\n";
Test script:
---------------
$endOfWeek = new DateTime();
$endOfWeek->modify('this week +6 days');
echo $endOfWeek->format('Y-m-d H:m:s')."\n";
echo $endOfWeek->format('U')."\n";
/* Thar she blows! */
echo $endOfWeek->getTimestamp()."\n";
echo $endOfWeek->format('Y-m-d H:m:s')."\n";
Expected result:
----------------
DateTime should stay the same after a call to getTimestamp (surely
getTimestamp should be safe from side effects)
--
Edit bug report at http://bugs.php.net/bug.php?id=52454&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52454&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52454&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52454&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52454&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52454&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52454&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52454&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52454&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52454&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52454&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52454&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52454&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52454&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52454&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52454&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52454&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52454&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52454&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52454&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52454&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52454&r=mysqlcfg