Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Time elapsed for index page
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2022-02-04 00:16:59
I use this and just thought I would post it since I dont believe its posted anywhere here. This uses a different time function for your torrents listed on the index page under "added".
Find in functions.php
            case 'added':
              print("<td class='ttable_col$x' align='center'>".date("n-d-Y g:i a", utc_to_tz_time($row['added']))."</td>");
           break;

change to
            case 'added':
               print("<td class='ttable_col$x' align='center'>".get_time_elapsed($row['added'])."</td>");
           break;

add this new function somewhere in the same file
///ELAPSED TIME SINCE TORRENT WAS UPLOADED
function get_time_elapsed($datetime, $full = false)
{
   $now = new DateTime;
   $ago = new DateTime($datetime);
   $diff = $now->diff($ago);
   $diff->w = floor($diff->d / 7);
   $diff->d -= $diff->w * 7;
   $string = array(
       'y' => 'year',
       'm' => 'month',
       'w' => 'week',
       'd' => 'day',
       'h' => 'hour',
       'i' => 'minute',
       's' => 'second',
   );
   foreach ($string as $k => &$v)
   {
       if ($diff->$k)
       {
           $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
       }
       else
       {
           unset($string[$k]);
    }
   }
   if (!$full) $string = array_slice($string, 0, 1);
   return $string ? implode(', ', $string) . ' ago' : 'just now';
}
///END ELAPSE TIME

Screenshot 2022-02-03 191643.jpg
File missing

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2022-02-05 15:54:34
#1 thanks 😉
2022-02-06 20:14:21
very cool  thanks
2022-02-06 23:00:31
It's been in the v4 files since the first posted, check out /site.php - its a treasure trove of neat functions.

Alternatively, you can do this to


function get_time_elapsed($datetime)
{
   return round((((time() - strtotime($datetime)) / 60) / 60) / 24) . ' day(s) ago';
}


Or...


function get_time_elapsed($time)
{
   $time   = time() - $time;
   $time   = ($time < 1) ? 1 : $time;
   $tokens = array(
       31536000 => 'year',
       2592000 => 'month',
       604800 => 'week',
       86400 => 'day',
       3600 => 'hour',
       60 => 'minute',
       1 => 'second'
   );
   foreach ($tokens as $unit => $text) {
       if ($time < $unit)
           continue;
       $numberOfUnits = floor($time / $unit);
       return $numberOfUnits . ' ' . $text . (($numberOfUnits > 1) ? 's' : '') . ' ago';
   }
}


etc etc. The one posted, that was from stackoverflow is the best because you get that "Just Now" feature.
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728