我試圖提高從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!"
?>
是可以將這些功能組合在一起還是有更好的方法來做到這一點?
在此先感謝。