...

View Full Version : time ago not showing for all files



pagedrop
07-15-2012, 09:07 PM
Hello,

I got this below code to be working.. BUT it seems to show the timeago for all the files the same thing..


//begin timeago
$time = "".fileatime("users/$username$viewurl/$filearray[$index]");
function humanTiming ($time)
{


$time = time() - $time; // to get the time since that moment

$tokens = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);

foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
}

}
//end of timeago

and here is the code which list all the files in my directory including the echo of the above ...


echo "<a id=\"$filearray[$index]\" href=\"readfile.php?file=" . $username . "/" . $filearray[$index] . "\">" . $filearray[$index] . "</a> ";
if($kbsize<1024)
{

echo "".round(($fileinfo['size']/1024),2)." KB ";
echo ''.humanTiming($time).' ago';


}
else
{
echo "".round((($fileinfo['size']/1024)/1024),2)." MB ";
echo ''.humanTiming($time).' ago';
}


How can I modify or would you please help in a way, the timeago loops or works for each individual file and show time individually?

thank you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum