Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] Birthday bug (again?)
#1
Hello,

I just looked at my profile.

Birthday: 16-08-1989 (18 years old) and I'm only 17. Smile
[Image: destroyerjf8.jpg]

Give us your feedback about MyBB in this thread and become listed on the MyBB website.
#2
Birthday: Saturday, November 18th, 1978 (29 years old)

mine is off as well

seems like they are calculating the year you are turning 29 even though its not the date yet
#3
Pretty sure it's duplicate: http://community.mybboard.net/showthread.php?tid=19252
#4
No, I was using that fixed file, Tikitiki.
[Image: destroyerjf8.jpg]

Give us your feedback about MyBB in this thread and become listed on the MyBB website.
#5
This Fix is from Michael83. He post it in german myBB.

Open member.php and search:
$lang->membdayage = sprintf($lang->membdayage, ($year - $membday['2'])); 

replace with:

$lang->membdayage = sprintf($lang->membdayage, ($year - $membday['2'] - 1));
#6
i am still alive Wrote:This Fix is from Michael83. He post it in german myBB.

Open member.php and search:
$lang->membdayage = sprintf($lang->membdayage, ($year - $membday['2'])); 

replace with:

$lang->membdayage = sprintf($lang->membdayage, ($year - $membday['2'] - 1));

Tested ::

For ex. i fill in as bday [ 20 January 1985 ]
result :: 21y (should be 22)

Edit ::

I've changed the thing into ... and seems to work =P
			$age = get_age($memprofile['birthday']);
			$lang->membdayage = sprintf($lang->membdayage, $age);
#7
Great. Now we're back to the original code...
#8
Fixed.

(You may also download the two attached files and replace inc/functions.php and ./member.php with them.
Instructions for fixing.

Open up inc/functions.php and find:
function get_age($birthday)
{
        $bday = explode("-", $birthday);
        if($bday[2] < 1970)
        {
                $years = 1970-$bday[2];
                $year = $bday[2]+($years*2);
                $stamp = mktime(0, 0, 0, $bday[1], $bday[0], $year)-($years*31556926*2);
        }
        else
        {
                $stamp = mktime(0, 0, 0, $bday[1], $bday[0], $bday[2]);
        }
        $age = floor((time()-$stamp)/31556926);
        return $age;
}

Replace with:
function get_age($birthday)
{
	$bday = explode("-", $birthday);
	if(!$bday[2])
	{
		return;
	}

	list($day, $month, $year) = explode("-", my_date("j-n-Y", time(), 0, 0));

	$age = $year-$bday[2];

	if(($month == $bday[1] && $day < $bday[1]) || $month < $bday[1])
	{
		--$age;
	}
	return $age;
}

Open member.php and find:
$lang->membdayage = sprintf($lang->membdayage, ($year - $membday['2']));

Replace with:
$lang->membdayage = sprintf($lang->membdayage, get_age($memprofile['birthday']));


Attached Files
.php   member.php (Size: 42.66 KB / Downloads: 193)
.php   functions.php (Size: 93.44 KB / Downloads: 206)
#9
Not fixed =P
If you enter 14 May 1985 , it returns 21y ! ( should be 22 )
If the month is different from the one it actually is ex. you enter 14 March 1985 , it returns 22y. And 14 September 1985 returns 21y, that's correct =P

Edit ::

This
	if(($month == $bday[1] && $bday[1] < $day) || $month < $bday[1])

Should become
	if(($month == $bday[1] && $bday[0] > $day) || $month < $bday[1])
#10
[edit] That'll teach me for forgetting to submit the Quick Reply form for 20 minutes. Rolleyes

Actually it didn't - it caused wrong ages to be displayed.

There was a typo in what I pasted above.
if(($month == $bday[1] && $bday[1] < $day) || $month < $bday[1])

Should be:
if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])


Forum Jump:


Users browsing this thread: 1 Guest(s)