Jump to content

Calculate age in a banner based on birthday field


Alex.1

Recommended Posts

Hi @Alejandro

I have seen this already https://www.jreviews.com/docs/developers/custom-field-php-formatting#calc-age-based-on-birth-date

and trying to adjust it in order to have a banner field jr_age where to calculate the age based on the birthday (jr_dob).

In the PHP Output Format I have this: 

$bday = $CustomFields->fieldValue('jr_dob',$entry);

$today = new DateTime();
$diff = $today->diff($bday);
return $diff->y;

In the Banner Code i have {jr_age}

I have tried different variations as well but with no result...

What am I doing wrong here?

Thank you

Link to comment
×
×
  • Create New...