1 (edited by essell 2006-08-10 12:28)

Topic: replacing timestamps with "posted 47 minutes ago" etc.

I'd love if it the timestamps on the index and viewforum pages could be set to a "14 minutes ago" or "4 weeks ago" format. I find it much clearer and more informative at a glance, than looking at the date and time, then comparing it to the current date and time, etc.

If there's a mod out there that already does this, then please point me in its direction smile

Re: replacing timestamps with "posted 47 minutes ago" etc.

There's no mod out there to do this that I know of, but this PHP class has a function to print out a date in that format. With a little modding, you might be able to get PunBB to use that.

Looking for a certain modification for your forum? Please take a look here before posting.

Re: replacing timestamps with "posted 47 minutes ago" etc.

I would really like this also...the link your supplied pogenwurst is now not working

Also since last year maybe someone has done this??

any help would be awesome smile

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: replacing timestamps with "posted 47 minutes ago" etc.

http://www.avengex.com/tutorials/82
That should be all the code you need to integrate it smile

Although I would take this:

$wcount = 0;
for($wcount = 0; $difference>$week; $wcount++) {
$difference = $difference - $week;
}
$dcount = 0;
for($dcount = 0; $difference>$day; $dcount++) {
$difference = $difference - $day;
}
$hcount = 0;
for($hcount = 0; $difference>$hour; $hcount++) {
$difference = $difference - $hour;
}
$mcount = 0;
for($mcount = 0; $difference>$minute;
$mcount++) {
$difference = $difference - $minute;
}

and instead do this (I think this code should work, tell me if it doesn't)

$wcount = floor($difference / $week);
$difference = $difference - ($wcount * $week);

$dcount = floor($difference / $day);
$difference = $difference - ($dcount * $day);

$hcount = floor($difference / $hour);
$difference = $difference - ($hcount * $hour);

$mcount = floor($difference / $minute);
$difference = $difference - ($mcount * $minute);
http://fluxbb.org

Free PunBB Hosting - lots of mods, easy to customize

5 (edited by nickfzx 2007-06-04 19:41)

Re: replacing timestamps with "posted 47 minutes ago" etc.

thanks for the quick response...I found a good solution just by messing with the code of punbbs date function (inspired by this post: http://punbb.org/forums/viewtopic.php?id=7436)


here is my code:

function format_time($timestamp, $date_only = false)
{
    global $pun_config, $lang_common, $pun_user;

    if (!$date_only)
        {
            $diff = time() - $timestamp;
            $rest = ($diff % 3600);
            $restdays = ($diff % 86400);
            $restweeks = ($diff % 604800);
            $weeks = ($diff - $restweeks) / 604800;
            $days = ($diff - $restdays) / 86400;
            $hours = ($diff - $rest) / 3600;
            $seconds = ($rest % 60);
            $minutes = ($rest - $seconds) / 60;
            if ($timestamp == '')
                return $lang_common['Never'];
            if($weeks > 1)
                return $date."$weeks weeks ago";
            elseif($days > 1)
                return $date."$days days ago";
            elseif($hours > 1)
                return $date."$hours hours ago";
            elseif ($hours == 1)
                return $date."1 hour, $minutes mins ago";
            elseif ($minutes == 0)
                return $date."$seconds seconds ago";
            elseif ($minutes == 1)
                return $date."1 minute ago";
            elseif ($seconds < 60)
                return $date."$minutes mins ago";
        }
        else{
            $diff = ($pun_user['timezone'] - $pun_config['o_server_timezone']) * 3600;
            $timestamp += $diff;
            $now = time();

            $date = date($pun_config['o_date_format'], $timestamp);
            $today = date($pun_config['o_date_format'], $now+$diff);
            $yesterday = date($pun_config['o_date_format'], $now+$diff-86400);

            return $date;
           }
}
Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: replacing timestamps with "posted 47 minutes ago" etc.

I'd also like this added to 1.3

Re: replacing timestamps with "posted 47 minutes ago" etc.

Alternative date/time schemes would be extensions smile

http://fluxbb.org

Free PunBB Hosting - lots of mods, easy to customize

Re: replacing timestamps with "posted 47 minutes ago" etc.

essell wrote:

I find it much clearer and more informative at a glance, than looking at the date and time, then comparing it to the current date and time, etc.

I agree, this would be way more meaningful!!

can someone please mod this now for 1.2? (no point waiting for extensions to 1.3 - it ain't even finished...)
I'm no expert but this sounds pretty easy to do/minimal files to change smile

Re: replacing timestamps with "posted 47 minutes ago" etc.

nickfzx's post above didn't help?

http://fluxbb.org

Free PunBB Hosting - lots of mods, easy to customize

Re: replacing timestamps with "posted 47 minutes ago" etc.

where do you paste that code?
what code do you replace?
filenames to edit and line numbers would help me a lot

Re: replacing timestamps with "posted 47 minutes ago" etc.

format_time function in include/functions.php

http://fluxbb.org

Free PunBB Hosting - lots of mods, easy to customize

Re: replacing timestamps with "posted 47 minutes ago" etc.

cheers, works well, but I really want to still have the timestamp but have the "posted 47 minutes ago" after the timestamp in brackets
that's the best of both worlds!!

Re: replacing timestamps with "posted 47 minutes ago" etc.

nickfzx wrote:

thanks for the quick response...I found a good solution just by messing with the code of punbbs date function (inspired by this post: http://punbb.org/forums/viewtopic.php?id=7436)


here is my code:

function format_time($timestamp, $date_only = false)
{
    global $pun_config, $lang_common, $pun_user;

    if (!$date_only)
        {
            $diff = time() - $timestamp;
            // ....
    if ($timestamp == '') {
                        return $lang_common['Never'];
            }
            // ....

}

I'm not a good PHP developer, but this looks pretty strange to me.
I mean, you calculate using $timestamp and later you check if $timestamp has a propper value.
I think PHP takes care of this (at least it tries to).
But it would be better if you first check $timestamp for the propper value and then use it for calculating.