function how_long_ago($unixTime) {
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
);
$today = time();
$since = $today - $unixTime;
for ($i = 0, $j = count($chunks); $i < $j; $i++) {
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
if (($count = floor($since / $seconds)) != 0) {
break;
}
}
return $count == 1 ? '1 '.$name : "$count {$name}s";
}
$rssUnixTime = strtotime('Sat, Jun 5, 2010 19:20');
echo 'posted '.how_long_ago($rssUnixTime).' ago';