How to display a date as iso 8601 format with PHP

Posted by Matthew James Taylor on Stack Overflow See other posts from Stack Overflow or by Matthew James Taylor
Published on 2009-05-24T06:12:15Z Indexed on 2010/04/08 14:33 UTC
Read the original article Hit count: 316

Filed under:
|
|
|

I'm trying to display a datetime from my MySQL database as an iso 8601 formated string with PHP but it's coming out wrong.

17 Oct 2008 is coming out as: 1969-12-31T18:33:28-06:00 which is clearly not correct (the year should be 2008 not 1969)

This is the code I'm using:

<?= date("c", $post[3]) ?>

$post[3] is the datetime (CURRENT_TIMESTAMP) from my MySQL database.

Any ideas what's going wrong?

© Stack Overflow or respective owner

Related posts about iso-8601

Related posts about php