This is most likely very simple and easy to do but I can't figure out how to output the users age in vbulletin based on their registration birth date. There does not seem to be a variable built in for it. Any help would be appreciated.
Thanks.
--------------- Added [DATE]1207524531[/DATE] at [TIME]1207524531[/TIME] ---------------
I think all the code needs to do is subtract the birth date year from the current year to get the age. Could anyone help me?
--------------- Added [DATE]1207529081[/DATE] at [TIME]1207529081[/TIME] ---------------
Oh, after much hunting and pulling my hair out I figured out how to get the age of the user. Hope other people searching around find this of help.
The variable that holds the birthdate is
$vbulletin->userinfo['birthday']
To then turn it into an age I used
this function.
PHP Code:
function birthday ($birthday)
{
list($month,$day,$year) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($month_diff < 0) $year_diff--;
elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--;
return $year_diff;
}
echo birthday($vbulletin->userinfo['birthday']); //prints age