views:

434

answers:

1

Hello,

I am currently using PHP/MySQL and the jQuery timeago plugin. Basically, I need to pull my timestamp from the database and convert it to ISO 8601 format.

Like this 2008-07-17T09:24:17Z

Currently, my timestamps are in the database in this format:

0000-00-00 00:00:00

I have tried using timeago with my currently formatted timestamp, but it doesn't work. It just always says 'less than a minute ago.'

However, when I hardcode it in the ISO 8601 format, it works. Therefore, I need some help on either:

1) Using a SELECT statement to convert my timestamp into ISO 8601 format

2) Or, SELECT the timestamp and then convert to ISO 8601 with PHP.

Many thanks!!

+3  A: 

Try using the result from your SELECT statement in something like this:

$iso_date = date('c',strtotime($selected_timestamp));

That will use the variable $selected_timestamp from your db, convert it into a PHP timestamp, and then output the ISO 8601 timestamp into $iso_date.

BraedenP
Thanks Braeden. That worked great!
Dodinas