I have stored time of comment in DB as time();
now I need to use that to be able to use JQUERY TIME AGO PLUGIN. But not have any idea as how to convert it in to "2008-07-17T09:24:17Z" format so it can be used in plugin.
Asked
Active
Viewed 73 times
-1

Kundan Singh
- 83
- 10
-
3What you have tried so far? – Mangesh Parte Dec 24 '14 at 17:13
-
I can try with php date function but what does T and Z means? – Kundan Singh Dec 24 '14 at 17:15
-
completely disagree it to be duplicate....I never asked for javascript options. Request everyone to read the question first and then mark sensible duplicates – Kundan Singh Dec 24 '14 at 17:34
-
You asked for PHP answers, but tagged the question as jQuery. This means you are going to attract answers relating to jQuery and JavaScript. – Ramsay Smith Dec 26 '14 at 04:15
2 Answers
1
In php,
$isostring = date('c',$timevalue);
gets you the ISO8601 string. See here: http://php.net/manual/en/function.date.php
T is a separator splitting the date from the time. Z is a timezone indicator, meaning so-called Zulu time. That's aviator shorthand for the null timezone, also known as Universal Time Coordinated (UTC) formerly known as Greenwich Mean Time (GMT).

O. Jones
- 103,626
- 17
- 118
- 172
0
PHP has several constants that are used to covert to common date formats. Assuming you are accessing the time from a database, you can use strtotime()
to convert and then use the DATE_ISO8601
constant in PHP.
$dateformatted = date(DATE_ISO8601, strtotime($datefromdatabase));

Ramsay Smith
- 1,098
- 13
- 30