views:

42

answers:

4

Just a simple question. How do I convert a PHP ISO time (like 2010-06-23T20:47:48-04:00) to something more readable? Is there a function already built in PHP? I've looked around but I haven't seen anything to convert times. If there's not a function, is it possible?

Thank you

+1  A: 

Sounds like you're looking for the date function: http://php.net/manual/en/function.date.php

Possibly paired with the strtotime function: http://www.php.net/manual/en/function.strtotime.php

JGB146
May work, but `date()` requires the timestamp to be an integer - therefore it won't work if the ISO time is already a string.
a_m0d
See my edit, referencing the strtotime function.
JGB146
+1  A: 
$format = "d M Y"; //or something else that date() accepts as a format
date_format(date_create($time), $format);
zebediah49
Staring me in the face the whole time. Thank you
Dylan Taylor
A: 

I think you should try strftime

http://www.php.net/manual/en/function.strftime.php

DjDarkman
+1  A: 

strptime() converts a string containing a time/date with the format passed as second argument to the function. The return value is an array containing values for day, month, year, hour, minutes, and seconds; you can use those values to obtain a string representing the date in the format you like.

strptime() is available since PHP 5.1.0, while the class DateTime is available since PHP 5.2.0.

kiamlaluno