Bug #53225 [NEW]: add-Method of DateTime-class

From: Date: Tue, 02 Nov 2010 07:41:25 +0000
Subject: Bug #53225 [NEW]: add-Method of DateTime-class
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155700@lists.php.net to get a copy of this message
From:             
Operating system: Mac OS X 10.5.8
PHP version:      5.3SVN-2010-11-02 (snap)
Package:          Date/time related
Bug Type:         Bug
Bug description:add-Method of DateTime-class 

Description:
------------
PHP-Version:
PHP 5.3.99-dev (cli) (built: Nov  1 2010 17:42:09) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2010 Zend Technologies

If a timezone is passed in the time-string to the constructor of the
DateTime-Object, a subsequent add() call could result in incorrect results
(if the add() call oversteps a daylight-saving time).

Test script:
---------------
// Gives expected result
$date = new DateTime('2010-10-31 01:00 CEST', new
DateTimeZone("Europe/Zurich"));
$date->setTimezone(new DateTimeZone('Europe/Zurich'));
$date->add(new DateInterval('PT3H'));
echo $date->format('Y-m-d H:i:sP')."\n";

// Doesn't give expected result
$date = new DateTime('2010-10-31 01:00 CEST', new
DateTimeZone("Europe/Zurich"));
$date->add(new DateInterval('PT3H'));
$date->setTimezone(new DateTimeZone('Europe/Zurich'));
echo $date->format('Y-m-d H:i:sP')."\n";

Expected result:
----------------
2010-10-31 04:00:00+01:00
2010-10-31 04:00:00+01:00


Actual result:
--------------
2010-10-31 04:00:00+01:00
2010-10-31 03:00:00+01:00


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



Thread (2 messages)

« previous php.bugs (#155700) next »