Bug #62561 [NEW]: DateTime add 'P1D' adds 25 hours

From: Date: Fri, 13 Jul 2012 21:41:28 +0000
Subject: Bug #62561 [NEW]: DateTime add 'P1D' adds 25 hours
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-171931@lists.php.net to get a copy of this message
From:             zach dot bailey at pardot dot com
Operating system: Mac OS X 10.7.4
PHP version:      5.3.14
Package:          Date/time related
Bug Type:         Bug
Bug description:DateTime add 'P1D' adds 25 hours

Description:
------------
When a DateTime is constructed with a non-UTC timezone and one day is
added, the 
time also jumps forward by an hour as well.

Test script:
---------------
$ts = new DateTime('@1341115200', new DateTimeZone('America/New_York'));

$dayFromTs = new DateTime('@1341115200', new
DateTimeZone('America/New_York'));
$dayFromTs->add(new DateInterval('P1D'));

echo 'ts: '.$ts->format('Y-m-d H:i:s')."\n";
echo 'day from ts: '.$dayFromTs->format('Y-m-d H:i:s')."\n";

Expected result:
----------------
ts: 2012-07-01 04:00:00
day from ts: 2012-07-02 04:00:00

Actual result:
--------------
ts: 2012-07-01 04:00:00
day from ts: 2012-07-02 05:00:00

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62561&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=62561&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=62561&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=62561&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=62561&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62561&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=62561&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=62561&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=62561&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=62561&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=62561&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=62561&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=62561&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=62561&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=62561&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=62561&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62561&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=62561&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=62561&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=62561&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=62561&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=62561&r=mysqlcfg



Thread (9 messages)

« previous php.bugs (#171931) next »