Thanks a lot for pushing me in the right direction.
This is what I needed tho:
function duration ($seconds, $suffix=FALSE) {
$takes_time = array(604800,86400,3600,60,0);
$suffixes = array("Week","Day","Hour","Minute","Second");
$delimeter = array(" W ", " D ", ":",":","");
$output = "";
foreach ($takes_time as $key=>$val) {
${$suffixes[$key]} = ($val == 0) ? $seconds : floor(($seconds/$val));
$seconds -= ${$suffixes[$key]} * $val;
if (${$suffixes[$key]} > 0 || (!empty($output) && $suffix == FALSE)) {
if ($val == 0 && $suffix == FALSE && empty($output)) {
$output .= "00:";
}
$output .= ($key > 1 && strlen(${$suffixes[$key]}) == 1 && $suffix == FALSE) ? "0".${$suffixes[$key]} : ${$suffixes[$key]};
if ($suffix == "short") {
$output .= substr($suffixes[$key],0,1)." ";
}
elseif ($suffix == "long") {
$output .= (${$suffixes[$key]} > 1) ? " ".$suffixes[$key]."s " : " ".$suffixes[$key]." ";
}
else {
$output .= $delimeter[$key];
}
}
}
return $output;
}
$result = mysql_query('SELECT * FROM users ORDER BY last_login DESC LIMIT 5');
while ($row = mysql_fetch_assoc($result))
{
$diff = time('g:i:s A') - strtotime($row['last_login']);
echo $row['username'] . ': ' . duration($diff,'long') . ' ago<br><br>';
}
(This is for anyone who happens to search the forums and need help with this).