Jump to content

Recommended Posts

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' [b]Wed Jun 07, 2006 10:40 pm[/b] 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]
Link to comment
https://forums.phpfreaks.com/topic/11468-help-how-do-i-get-this-script/
Share on other sites

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

[code]
    // 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 . '.';
    }
[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.