Bug #61028 [NEW]: DateTime constructor ignores Timezone info in DATE_ISO8601 formated strings

From: Date: Thu, 09 Feb 2012 15:04:22 +0000
Subject: Bug #61028 [NEW]: DateTime constructor ignores Timezone info in DATE_ISO8601 formated strings
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-167348@lists.php.net to get a copy of this message
From:             
Operating system: OpenSuse 12.1
PHP version:      5.3.10
Package:          Date/time related
Bug Type:         Bug
Bug description:DateTime constructor ignores Timezone info in DATE_ISO8601 formated strings

Description:
------------
DateTime ignores Timezone:

php -r '$d=new DateTime("2012-02-09T15:30:14+0100"); echo
$d->format(DATE_ISO8601)."\n"; $d=new DateTime("2012-02-09T14:30:14+0000");
echo $d->format(DATE_ISO8601)."\n";'

Output:
2012-02-09T15:30:14+0100
2012-02-09T14:30:14+0000


strtotime works as expected:

php -r 'echo date(DATE_ISO8601,
strtotime("2012-02-09T15:30:14+0100"))."\n"; echo date(DATE_ISO8601,
strtotime("2012-02-09T14:30:14+0000"))."\n";'

Output:
2012-02-09T15:30:14+0100
2012-02-09T15:30:14+0100


Test script:
---------------
php -r '$d=new DateTime("2012-02-09T15:30:14+0100"); echo
$d->format(DATE_ISO8601)."\n"; $d=new DateTime("2012-02-09T14:30:14+0000");
echo $d->format(DATE_ISO8601)."\n";'


Expected result:
----------------
2012-02-09T15:30:14+0100
2012-02-09T15:30:14+0100


Actual result:
--------------
2012-02-09T15:30:14+0100
2012-02-09T14:30:14+0000


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



Thread (2 messages)

« previous php.bugs (#167348) next »