Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: MOD: Change Time and Date stamp from "y-m-d" to "1 hour 5 mins ago"  (Read 11618 times)

0 Members and 1 Guest are viewing this topic.

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285

so this is what to do if you want to change coppermine to display dates and times as backward countdowns from the time of the event...e.g:

File Added 5 mins ago, comment made 2 days ago

instead of the current very regimental style of displaying the whole date and 24 hour clock.

you open functions.inc.php and replace the entire
Code: [Select]
function localised_date($timestamp = -1, $datefmt)function

with this:
Code: [Select]
function localised_date($timestamp)
{

            $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";

}

I have not tested it extensively but it seems to work ok...I will update if I find any problems with it.

Also not sure if I am supposed to release mods that involve editing core files...so apologies GauGau if this is a problem...I am only trying to contribute something.
« Last Edit: June 04, 2007, 11:39:08 pm by nickfzx »
Logged

Nibbler

  • Guest
Re: MOD: Change Time and Date stamp from "y-m-d" to "1 hour 5 mins ago"
« Reply #1 on: June 04, 2007, 11:27:24 pm »

Does this mod require punbb integration?
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: MOD: Change Time and Date stamp from "y-m-d" to "1 hour 5 mins ago"
« Reply #2 on: June 04, 2007, 11:29:38 pm »

no it doesn't, there is (was, I will edit out now) some punbb code left in there from my install

sorry for not seeing that :)


edit: now taken out the punbb code I had accidentally left in there
« Last Edit: June 05, 2007, 02:10:50 pm by nickfzx »
Logged

Fudgemaster

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 45
    • Trackdays, Car shows, Nature and some misc photos
Re: MOD: Change Time and Date stamp from "y-m-d" to "1 hour 5 mins ago"
« Reply #3 on: June 21, 2007, 10:17:01 pm »

Thanks.

Works like a charm.

One modification I'd like to see tho..
In some point, like 1 months or so, it would switch back to showing the actual date..
So there wouldn't be a ton of "added 500 weeks ago" lines :)
Logged
--
It's an insane world.. But I'm proud to be a part of it.

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: MOD: Change Time and Date stamp from "y-m-d" to "1 hour 5 mins ago"
« Reply #4 on: June 26, 2007, 12:38:02 pm »

yeah would be nice...i will do it at some point...I wanted to do it as "3 months ago" for example but you get the whole problem with the months having different numbers of days in them.

When I get round to the fix I'll post it here.
Logged
Pages: [1]   Go Up
 

Page created in 0.039 seconds with 19 queries.