1
i've added a function to calculate someone's age from the MySQL date format.
in functions.php added:
function CalcAge($date_of_birth) { // YYYY-MM-DD
$cur_year=date("Y");
$cur_month=date("m");
$cur_day=date("d");
$dob_year=substr($date_of_birth, 0, 4);
$dob_month=substr($date_of_birth, 5, 2);
$dob_day=substr($date_of_birth, 8, 2);
if($cur_month>$dob_month || ($dob_month==$cur_month && $cur_day>=$dob_day) )
return $cur_year-$dob_year;
else
return $cur_year-$dob_year-1;
}
so what i want now is for the age to be displayed on userinfo.php instead of the date of birth.
in userinfo.php i have the following >
$xoopsTpl->assign('user_birth', $thisUser->getVar('user_birth'));
which gets the date of birth value ok, and i then use the smarty tag <{user_birth}> in the template to display date of birth.
but what i want is to use the age calculation function that i added to functions.php and instead of showing date of birth, i want it to show the result of the calculation as AGE..
so then possibly have
$xoopsTpl->assign('user_age', $thisUser->getVar('user_age'));
in the template and user_age being the result of the calculation..
can any1 help with this?