Want to display a different message if the time is under a certain amount. I have then function that I have been working on, but cannot not get it to work unless the if for time is 1. Would like 10 minutes.
function TimeSince($timestamp)
{
// array of time period chunks
$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'),
);
// difference in seconds
$since = time() - $timestamp;
// calculate one chunk of time
for ($i = 0, $j = count($chunks); $i < $j; $i++)
{
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
// finding the biggest chunk (if the chunk fits, break)
if (($count = floor($since / $seconds)) != 0)
{
break;
}
}
// set output var
$output = ($count == 1) ? '1 '.$name : "$count {$name}s";
// Displays time of if under 10 minutes displays Just Now
if($output < 10) {
return ("Just Now!");
}
else {
return ($output . " ago");
}
return $output;
}