Hope I can get help with a little piece of code I found a long time ago.
I use it to display how long a user have been member.
But it does not work properly.
The code:
Code: Select all
// how long a member for
$member_for = '';
if ($this->user->data['is_registered'] && !$this->user->data['is_bot'])
{
$member_length = (int) time() - (int) $this->user->data['user_regdate'];
$years = $months = $days = 0;
$member_for = '';
if ($member_length)
{
if ($member_length >= 31536000)
{
$years = (int) ($member_length / 31536000);
$member_length = (int) $member_length - ( (int) $years * 31536000);
$member_for .= $years > 1 ? ((int) $years . ' ' . $this->user->lang['WELCOME_YEARS'] . ', ') : ((int) $years . ' ' . $this->user->lang['WELCOME_YEAR'] . ', ');
}
$months = (int) ($member_length / 2628000);
if ($months)
{
$member_length = (int) $member_length - ((int) $months * 2628000);
$months = (int) $months > 1 ? ((int) $months . ' ' . $this->user->lang['WELCOME_MONTHS'] . ', ') : ((int) $months . ' ' . $this->user->lang['WELCOME_MONTH'] . ', ');
$member_for .= $months;
}
$days = (int) ($member_length / 86400);
if ($days)
{
$member_length = (int) $member_length - ((int) $days * 86400);
$days = (int) $days > 1 ? ((int) $days . ' ' . $this->user->lang['WELCOME_DAYS']) : ($days . ' ' . $this->user->lang['WELCOME_DAY']);
$member_for .= $days;
}
}
}
You joined: 12 May 2008, 23:26
You have been member for: 16 Years, 1 Month, 1 Day
or from another profile
You joined: 08 Mar 2010, 17:42
You have been member for: 14 Years, 3 Months, 5 Days
I do not have the knowledge to fix it, so I hope one of you can do it