Bug #66161 [Opn->Nab]: Inconsistent ISO-8601 hour offset format date_format and date('c')

From: Date: Sun, 24 Nov 2013 21:14:30 +0000
Subject: Bug #66161 [Opn->Nab]: Inconsistent ISO-8601 hour offset format date_format and date('c')
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182907@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66161&edit=1 ID: 66161 Updated by: derick@php.net Reported by: martijn at webfauna dot nl Summary: Inconsistent ISO-8601 hour offset format date_format and date('c') -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: Debian 4.6.3 PHP Version: 5.5.6 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 "c" is *an* ISO8601 date format, and so is the one represented by DateTime::ISO8601. There are plenty of different possibilities for ISO8601 formats and they are just slightly different. The constant DateTime::ISO8601 represents "Y-m-d\TH:i:sO", but nothing stops you from using ->format('c') instead. We can't change either constant/format as people might rely on it. Previous Comments: ------------------------------------------------------------------------ [2013-11-24 11:46:00] martijn at webfauna dot nl Description: ------------ The formatting of the hour offset in date_format()/DateTime->format() differs from the one in date(). Both are correct according to the ISO-8601 specification, though I would expect a consistent format. Test script: --------------- date_default_timezone_set("Europe/Amsterdam"); $timeStamp = 1276592400; $dateTest = new DateTime(date('c', $timeStamp)); echo $dateTest->format(DateTime::ISO8601) ."\n"; echo date_format($dateTest, DateTime::ISO8601)."\n"; echo date('c', $timeStamp) ."\n"; Expected result: ---------------- EITHER 1276592400 2010-06-15T11:00:00+0200 2010-06-15T11:00:00+0200 2010-06-15T11:00:00+0200 OR 1276592400 2010-06-15T11:00:00+02:00 2010-06-15T11:00:00+02:00 2010-06-15T11:00:00+02:00 Actual result: -------------- 1276592400 2010-06-15T11:00:00+0200 2010-06-15T11:00:00+0200 2010-06-15T11:00:00+02:00 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66161&edit=1

« previous php.bugs (#182907) next »