I’m trying to improve the readibility of a published date being pulling in from a twitter XML file.
Currently the time date being displayed is 2012-02-10T14:20:08Z
I have applied a regex to this and now displays 2012-02-10 14:20:08 GMT
Now all i need to do is to convert the date from the US format to the UK format. I have looked into this and see it is possible to use strtodate function. But I’m unsure on how to go about doing this.
<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!"
?>
Is is possible to combine these functions together or is there a better way to do this?
Thanks in advance.
See the
date()format syntax if you want to change it. Seestrtotime()documentation to understand how it works.