Re: possible bug in date()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It appears this is a known bug that is/will be fixed in PHP 5.1.3. The current date code for DATE_W3C and DATE_ATOM (in 5.1.2) is "Y-m-d\TH:i:sO". According to http://us3.php.net/manual/en/function.date.php , the other option for the last character is "P" which prints the difference from Greenwich mean time with a colon (as the examples for DATE_W3C and DATE_ATOM suggest).

As a workaround, I've found that the string "c" produces the output I was expeciting to get from DATE_W3C and DATE_ATOM.

This code:
    $this->dateCreated = date( "c", ATOM, mktime( 0, 0, 0, 23, 2, 2006 ) );

Outputs this:
    2006-02-23T00:00:00-08:00

Mark

Mark Slater wrote:
I'm trying to create a date with the DATE_W3C or DATE_ATOM format (they are the same format according to the examples), but the output of date doesn't match the example in the documentation.

The http://us3.php.net/manual/en/ref.datetime.php page says the formats are as follows:

DATE_ATOM (string)
Atom (example: 2005-08-15T15:52:01+00:00)

DATE_W3C (string)
World Wide Web Consortium (example: 2005-08-15T15:52:01+00:00)

DATE_ISO8601 (string)
ISO-8601 (example: 2005-08-15T15:52:01+0000)


If I create a date with this code:

    $this->dateCreated = date( DATE_ATOM, mktime( 0, 0, 0, 23, 2, 2006 ) );
    echo $this->dateCreated;

I expect to see:

    2006-02-23T00:00:00-08:00

The output I actually get is the ISO-8601 format:

    2006-02-23T00:00:00-0800

The only difference is the colon in the GMT offset at the end.

Is the example output in the web page wrong? Or is this a bug in PHP?

Thanks,

Mark

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux