Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 30
  1. #11
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    No... basically you said you MADE it... "I made this, it basically works abit like facebooks timer (under status' & posts etc..)".

  2. #12
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    No... basically you said you MADE it... "I made this, it basically works abit like facebooks timer (under status' & posts etc..)".
    Hence why I said I meant edit

    Lew.
    Im not here to be loved, I love to be hated :-}


  3. #13
    Join Date
    Jul 2004
    Location
    California
    Posts
    8,725
    Tokens
    3,789
    Habbo
    HotelUser

    Latest Awards:

    Default

    Quote Originally Posted by LMS16 View Post
    Hence why I said I meant edit

    Lew.
    I think it might be best to call a spade a spade and just move on - next time perhaps use a better vocabulary when posting snippets
    I'm not crazy, ask my toaster.

  4. #14
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Now HotelUser, a spade isn't a spade! There's box shovels, round shovels, plumbers shovels, gardening shovels.

    Well.. a spade's a spade I reckonnn!

  5. #15
    Join Date
    Jul 2005
    Location
    Leeds
    Posts
    947
    Tokens
    0
    Habbo
    Flumples

    Default

    Quote Originally Posted by Trinity View Post
    That's not what he asked for though, he wants to display the number of days, not seconds/minutes/hours.



    That wouldn't work, it says time() - time().

    I'd do this:
    PHP Code:
    function plural($num) {
        if (
    $num != 1)
            return 
    "s";
    }
     
    function 
    getRelativeTime($date) {
        
    $diff time() - $date;
        if (
    $diff<60)
            return 
    $diff " second" plural($diff) . " ago";
        
    $diff round($diff/60);
        if (
    $diff<60)
            return 
    $diff " minute" plural($diff) . " ago";
        
    $diff round($diff/60);
        if (
    $diff<24)
            return 
    $diff " hour" plural($diff) . " ago";
        
    $diff round($diff/24);
        if (
    $diff<7)
            return 
    $diff " day" plural($diff) . " ago";
        
    $diff round($diff/7);
        if (
    $diff<4)
            return 
    $diff " week" plural($diff) . " ago";
        return 
    "on " date("F j, Y"strtotime($date));
    }

    // Unix timestamp for today at 17:21:19, replace this with a timestamp for whenever you want
    $stampystamp 1295803279;

    // Display the number of seconds/minutes/hours/days/weeks since the timestamp
    echo getRelativeTime($stampystamp); 
    Untested and rushed, but should work.
    Sorry, don't mean to bump, but this has broken now! :S

    It now displays 'on January 1, 1970' as the output.. any ideas?

  6. #16
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by Flumples View Post
    Sorry, don't mean to bump, but this has broken now! :S

    It now displays 'on January 1, 1970' as the output.. any ideas?
    Significance of that date in case it helps - http://en.wikipedia.org/wiki/January_1,_1970
    Post the code that you're actually using.

  7. #17
    Join Date
    Jul 2005
    Location
    Leeds
    Posts
    947
    Tokens
    0
    Habbo
    Flumples

    Default

    Thanks, I haven't actually changed anything yet cos it's the same as was posted earlier. It was working originally..

  8. #18
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by Flumples View Post
    Thanks, I haven't actually changed anything yet cos it's the same as was posted earlier. It was working originally..
    Yes, so post the code that you're using to call that function.
    Also, this is probably not the problem, but check your server's time/date settings.

  9. #19
    Join Date
    Jul 2005
    Location
    Leeds
    Posts
    947
    Tokens
    0
    Habbo
    Flumples

    Default

    PHP Code:
    function plural($num) {
        if (
    $num != 1)
            return 
    "s";
    }
     
    function 
    getRelativeTime($date) {
        
    $diff time() - $date;
        if (
    $diff<60)
            return 
    $diff " second" plural($diff) . " ago";
        
    $diff round($diff/60);
        if (
    $diff<60)
            return 
    $diff " minute" plural($diff) . " ago";
        
    $diff round($diff/60);
        if (
    $diff<24)
            return 
    $diff " hour" plural($diff) . " ago";
        
    $diff round($diff/24);
        if (
    $diff<7)
            return 
    $diff " day" plural($diff) . " ago";
        
    $diff round($diff/7);
        if (
    $diff<4)
            return 
    $diff " week" plural($diff) . " ago";
        return 
    "on " date("F j, Y"strtotime($date));
    }

    // Unix timestamp for today at 17:21:19, replace this with a timestamp for whenever you want
    $stampystamp 1295803279;

    // Display the number of seconds/minutes/hours/days/weeks since the timestamp
    echo getRelativeTime($stampystamp); 

  10. #20
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by Flumples View Post
    PHP Code:
    function plural($num) {
        if (
    $num != 1)
            return 
    "s";
    }
     
    function 
    getRelativeTime($date) {
        
    $diff time() - $date;
        if (
    $diff<60)
            return 
    $diff " second" plural($diff) . " ago";
        
    $diff round($diff/60);
        if (
    $diff<60)
            return 
    $diff " minute" plural($diff) . " ago";
        
    $diff round($diff/60);
        if (
    $diff<24)
            return 
    $diff " hour" plural($diff) . " ago";
        
    $diff round($diff/24);
        if (
    $diff<7)
            return 
    $diff " day" plural($diff) . " ago";
        
    $diff round($diff/7);
        if (
    $diff<4)
            return 
    $diff " week" plural($diff) . " ago";
        return 
    "on " date("F j, Y"strtotime($date));
    }

    // Unix timestamp for today at 17:21:19, replace this with a timestamp for whenever you want
    $stampystamp 1295803279;

    // Display the number of seconds/minutes/hours/days/weeks since the timestamp
    echo getRelativeTime($stampystamp); 
    No. You've just posted the code that I posted. Post the code that you are using to call the function.
    It should look a bit like this:
    PHP Code:
    echo getRelativeTime(1295803279); 
    You've probably used a variable instead of that timestamp though, so post the code that you use to assign a value to the variable too.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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