4images Forum & Community

4images Modifications / Modifikationen => Templates & Styles (Requests & Discussions) => Topic started by: edonai on August 18, 2009, 05:42:47 AM

Title: Show time to upload
Post by: edonai on August 18, 2009, 05:42:47 AM
Hello to all.
I would like to know how to display the time of upload in the MOD "new_images" ?
For example "5 hours ago" or "two days ago" etc..... ?

Thanks for your help

Edonai
Title: Re: Show time to upload
Post by: GaYan on August 18, 2009, 02:10:04 PM
That Great  :) Even Im Waiting for a mod Like this  :!: :wink:
Title: Re: Show time to upload
Post by: V@no on August 18, 2009, 03:06:36 PM
where do you want this to be showed? on each image instead of full date?
Title: Re: Show time to upload
Post by: Sunny C. on August 18, 2009, 03:10:59 PM
Nice. ^^
I Waiting for this mod too!
Title: Re: Show time to upload
Post by: Hagen-Roderich on August 18, 2009, 03:26:05 PM
where do you want this to be showed? on each image instead of full date?

On Signature MOD (http://www.4homepages.de/forum/index.php?topic=6755.msg139651#msg139651) please.
Title: Re: Show time to upload
Post by: edonai on August 18, 2009, 04:57:59 PM
where do you want this to be showed? on each image instead of full date?

Yes V@no, like this : http://www.theanimegallery.com/ (it's a beautiful site by IGC !)
Title: Re: Show time to upload
Post by: V@no on August 19, 2009, 02:46:58 AM
In includes/functions.php find:
  $timezone_offset = (defined("TIME_OFFSET")) ? TIME_OFFSET : 0;

Insert above:
  if (isset($user_info['date_alt']) && $user_info['date_alt'])
  {
    return format_date_alt($format, $timestamp);
  }


Above ?> insert:
function format_date_alt($format, $timestamp) //based on duration function from http://snipplr.com/view.php?codeview&id=2711
{
  global $user_info, $lang;

  $t = time() - ($timestamp + (3600 * (defined("TIME_OFFSET") ? TIME_OFFSET : 0)));
  $vals = array('y' => (int) ($t / 86400 / 365),
                'o' => (int) ($t / 86400 / 30),
                'w' => (int) ($t / 86400 / 7),
                'd' => $t / 86400 % 7,
                'h' => $t / 3600 % 24,
                'm' => $t / 60 % 60,
                's' => $t % 60);
  $ret = array();
  $added = false;
  foreach ($vals as $k => $v)
  {
    if ($v > 0 || $added)
    {
      $added = true;
      if ($v > 1)
      {
        $k = $lang['date_alt'][$k][1];
      }
      else
      {
        $k = $lang['date_alt'][$k][0];
      }
      $ret[] = $v . " " . $k;
    }
  }

  return join(' ', $ret);
}


In index.php find:
  $bgcounter = 0;

Insert below:
  $user_info['date_alt'] = 1;


Find:
unset($new_images);

Insert below:
unset($user_info['date_alt']);


In lang/<your language>/main.php above ?> insert:
$lang['date_alt'] = array(
  'y' => array("year", "years"),
  'o' => array("month", "months"),
  'w' => array("week", "weeks"),
  'd' => array("day", "days"),
  'h' => array("hour", "hours"),
  'm' => array("minute", "minutes"),
  's' => array("second", "seconds"),
);
Title: Re: Show time to upload
Post by: edonai on August 19, 2009, 12:49:14 PM
Thank you, you are super!
i follow your instruction, but the display is incorrect :

(http://img200.imageshack.us/img200/1898/sanstitre1yvu.th.png) (http://img200.imageshack.us/i/sanstitre1yvu.png/)

I call the function with the following tag: {image_date}
Title: Re: Show time to upload
Post by: V@no on August 19, 2009, 02:43:23 PM
ops, sorry, missed one step for main.php file..added in the instructions above.
Title: Re: Show time to upload
Post by: edonai on August 19, 2009, 07:59:09 PM
Big thanks V@no, you're great!  :P
Title: Re: Show time to upload
Post by: Sunny C. on August 19, 2009, 08:28:53 PM
Big THX V@no!
Added to my List: http://www.4homepages.de/forum/index.php?topic=24888.0