php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55272 Missing semicolon in DATE_ISO8601 Predefined Constant for date()
Submitted: 2011-07-23 20:39 UTC Modified: 2011-07-25 17:28 UTC
From: steve at stringersites dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.6 OS: Mac OS X
Private report: No CVE-ID: None
 [2011-07-23 20:39 UTC] steve at stringersites dot com
Description:
------------
It would appear that there is a mistake in the DATE_ISO8601 predefined constant 
for the date() function.

current output: 2011-07-22T00:00:00-0500
desired output: 2011-07-22T00:00:00-05:00 

http://www.php.net/manual/en/class.datetime.php#datetime.constants.iso8601

http://en.wikipedia.org/wiki/ISO_8601

Test script:
---------------
As best as I can tell, there's supposed to be a semicolon between the timezone offset hours:minutes.

<?php
$d = mktime (0, 0, 0, '03', '08', '2011');
// 2011-03-08T00:00:00-0600 <-- actual, incorrect (?) result
echo date(DATE_ISO8601, $d).'<br>';

// 2011-03-08T00:00:00-0600
echo date("Y-m-d\TH:i:sO", $d).'<br>';

// 2011-03-08T00:00:00-06:00 <-- expected result
echo date("Y-m-d\TH:i:sP", $d).'<br>';

?>

So the format for DATE_ISO8601 should be "Y-m-d\TH:i:sP" (capital P at the end), not "Y-m-d\TH:i:sO" (capital O at the end).

Expected result:
----------------
// 2011-03-08T00:00:00-0600 <-- actual, incorrect (?) result
echo date(DATE_ISO8601, $d);

Actual result:
--------------
// 2011-03-08T00:00:00-06:00 <-- expected result
echo date("Y-m-d\TH:i:sP", $d);

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-25 16:38 UTC] aharvey@php.net
-Status: Open +Status: Bogus -Package: Unknown/Other Function +Package: Date/time related
 [2011-07-25 16:38 UTC] aharvey@php.net
ISO 8601 explicitly allows time zone representations to be "basic" (without the 
colon), or "extended" (with the colon). Both are equally valid, and PHP implements 
the former in that particular constant.
 [2011-07-25 17:28 UTC] steve at stringersites dot com
Got it.  

Note that the Google Checkout XML API rejects the semicolon-less timestamp using 
the predefined constant. The only format it accepts is "Y-m-d\TH:i:sP".

Not that you're responsible for what Google does, but it's something to think 
about where the theoretical and practical collide.
 [2011-09-10 19:07 UTC] anon at anon dot com
This is a semi-colon -- ;
This is a colon -- :
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Aug 15 18:01:26 2020 UTC