I think I have a function which should do what you want:
function time2string($timeline) {
$periods = array('day' => 86400, 'hour' => 3600, 'minute' => 60, 'second' => 1);
foreach($periods AS $name => $seconds){
$num = floor($timeline / $seconds);
$timeline -= ($num * $seconds);
$ret .= $num.' '.$name.(($num > 1) ? 's' : '').' ';
}
return trim($ret);
}
Simply apply it to the difference between time()
and strtotime('2010-04-28 17:25:43')
as so:
print time2string(time()-strtotime('2010-04-28 17:25:43')).' ago';