Edit report at https://bugs.php.net/bug.php?id=61028&edit=1
ID: 61028 Updated by: der...@php.net Reported by: tom dot anheyer at berlinonline dot de Summary: DateTime constructor ignores Timezone info in DATE_ISO8601 formated strings -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: OpenSuse 12.1 PHP Version: 5.3.10 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php DateTime objects actually keep their timezone information, whereas strtotime() removes it (as a timestamp doesn't contain tz info). Previous Comments: ------------------------------------------------------------------------ [2012-02-09 15:04:22] tom dot anheyer at berlinonline dot de 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 this bug report at https://bugs.php.net/bug.php?id=61028&edit=1