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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Location
    Sutton-in-ashfield, Notts
    Posts
    117
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Needs help with this!

    PHP Code:
    <?php
        
    function ago($timestamp){
            
    $difference time() - $timestamp;

            if(
    $difference 60)
                return 
    $difference." seconds ago";
            else{
                
    $difference round($difference 60);
                if(
    $difference 60)
                    return 
    $difference." minutes ago";
                else{
                    
    $difference round($difference 60);
                    if(
    $difference 24)
                        return 
    $difference." hours ago";
                    else{
                        
    $difference round($difference 24);
                        if(
    $difference 7)
                            return 
    $difference." days ago";
                        else{
                            
    $difference round($difference 7);
                            return 
    $difference." weeks ago";
                        }
                    }
                }
            }
        }
    ?>
    Doing my head in its in my core file & i want to echo it like this
    echo $core->timestamp($posts['timestamp']);
    so it change's to

    about 1 min ago

    etc same as facebook lol thanks.

    Or something like facebook's been trying to find one but cant at all :L and i'll still learning php lol!

  • #2
    New Coder
    Join Date
    Nov 2010
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post
    Not really sure what your asking here. I dont see any problem with that code.

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Location
    Sutton-in-ashfield, Notts
    Posts
    117
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Fixed it & thanks.


  •  

    Posting Permissions

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