How to convert this date format in php?
I receive this date format from facebook and google docs:
2011-02-25T10:开发者_开发问答55:25+0000
How can I convert it to something like
25/02/2011 10:55:25
<?php
$date = new DateTime('2011-02-25T10:55:25+0000');
print $date->format('d/m/Y H:i:s');
?>
Please don't forget to set the correct time zone with this example. Refer to the datetime documentation on the php.net site for more details.
Use strtotime to get timestamp.
$ts = strtotime('2011-02-25T10:55:25+0000');
echo date('d/m/Y H:i:s', $ts);
That looks like SOAP format.
Try to read it in with DateTime class and give it out with your own format.
Look at ZeSimon's answer for the code.
$out = preg_replace( "/^([0-9]+)-([0-9]+)-([0-9]+)T([0-9]+:[0-9]+:[0-9]+)\+([0-9]+)/", "\$3/\$2/\$1 \$4", $in );
精彩评论