PHP Convert ISO dates to a more readable format?

Just a question. How do I convert PHP time (e.g. 2010-06-23T20: 47: 48-04: 00) to something more readable? Is there a feature already built into PHP? I looked around, but I did not see anything to convert time. If there is no function, is this possible?

thanks

+7
php datetime
source share
7 answers
$format = "d MY"; //or something else that date() accepts as a format date_format(date_create($time), $format); 
+16
source share

Try the following:

 echo date( "Ymd H:i:s", strtotime("2010-06-23T20:47:48-04:00") ); 

Format this part of "Ymd H: i: s" using the format from this documentation http://php.net/manual/en/function.date.php

+5
source share

It looks like you are looking for a date function: http://php.net/function.date

Perhaps paired with the strtotime function: http://php.net/function.strtotime

+1
source share

I think you should try strftime

http://php.net/function.strftime

+1
source share

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

strptime () is available with PHP 5.1.0, and the DateTime class is available with PHP 5.2.0.

+1
source share
 echo strftime("%b %e %Y at %l:%M %p", strtotime($ios)); 

will make

0
source share

Try this for a short time:

 $a_date = '2010-06-23T20:47:48-04:00'; echo date('Ym-d', strtotime($a_date)); 
0
source share

All Articles