我试图提高从twitter XML文件拉入发布日期的可读性。结合正则表达式和strtotime
目前所显示的时间日期是2012-02-10T14:20:08Z
我申请一个正则表达式这一点,现在显示2012-02-10 14:20:08 GMT
现在我需要做的是将日期从美国格式转换为英国格式。我已经看过这个,看到它可以使用strtodate函数。但我不确定如何去做这件事。
<strong>Tweets within 10 miles radius of London Eye</strong></br>
<?php
$feed = simplexml_load_file('http://search.twitter.com/search.atom?geocode=' . $feed1 . '%2C' . $range . '%22london%22&' . $lang . '&' . $amount);
if ($feed) {
foreach ($feed->entry as $item) {
$string = $item->published;
// $unixdate = strtotime($string);
// $ukDate = date('d/m/20y', $unixdate);
$find = array('/T/', '/Z/');
$replace = array(' ', ' GMT');
echo '<a href=\'' . $item->link->attributes()->href . '\'>' . $item->title . '</a>', '</br>' . preg_replace($find, $replace, $string), '</br>';
}
}
else
echo "Cannot find Twitter feed!"
?>
是可以将这些功能组合在一起还是有更好的方法来做到这一点?
在此先感谢。