Jump to content


Photo

HELP! How do i get this script ....


  • Please log in to reply
1 reply to this topic

#1 Thermohaline Conveyor

Thermohaline Conveyor
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 08 June 2006 - 08:12 AM

Hello everyone,

I've just set-up and modified a forum through PHPBB and am looking to modify the script that tells the user when the last post was created on my forum. The current format reads 'last post' Wed Jun 07, 2006 10:40 pm however i've been looking everywhere for a script i could use to change the format to: 1 minute ago, into hours 1 hour ago etc. into days 2 days ago into weeks, into months etc. Can anyone enlighten me on where i can get this script and how to modify it within the PHPBB environment. Any help will be much appreciated. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

A good example can be found here [a href=\"http://www.ubuntuforums.org/forumdisplay.php?f=77)\" target=\"_blank\"]Click Here[/a], note the last post 1 hour ago so on script, thats the script i need.

My forum is at [a href=\"http://www.met-monkey.co.uk/weather.forum/index.php\" target=\"_blank\"]This Address[/a]

#2 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 08 June 2006 - 12:03 PM

One of the function i wrote long ago. Maybe it'll give you and idea.

    // convert unix timestamp $t (in the past of current time)
    // and return a 'amount of time ago'
    function FormatTimeP($t)
    {
        $yield = time() - $t;
        $secs = abs($yield);

        $numdays = floor($secs / 86400);
        $numhours = floor(($secs % 86400) / 3600);
        $nummins = floor(($secs % 3600) / 60);

        $retval = '';
        if ($numdays > 0)
        {
            ($numdays > 1)? $retval .= "$numdays days, " : $retval .= "$numdays day, ";
        }

        if ($numhours > 0)
        {
            ($numhours > 1)? $retval .= "$numhours hours, " : $retval .= "$numhours hour, ";
        }

        if ($nummins > 0)
        {
            ($nummins > 1)? $retval .= "$nummins minutes" : $retval .= "$nummins minute";
        }

        if (strlen($retval) < 1)
            $retval = '0 minute';
            
        if ($numdays > 7) // if greater than 7 days, do not display hours, min info
            $retval = "$numdays days";

        if ($yield > 0)
            return $retval . ' ago.';
        else return $retval . '.';
    }

Life's too short for arguing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users