Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Oct 2005
    Posts
    61
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Lightbulb time ago not showing for all files

    Hello,

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

    PHP Code:
    //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',
            
    => '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 ...

    PHP Code:
    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
    Last edited by pagedrop; 07-15-2012 at 10:55 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •