{source}<?php
function calculateAge($birthdate) {
$today = new DateTime();
$birthDate = new DateTime($birthdate);
$age = $today->diff($birthDate)->y;
return $age;
}
$birthdate = "{article}[date-of-birth]{/article}";
$age = calculateAge($birthdate);
echo "Current Age: " . $age . " years";
?>
{/source}
{article}{source}<?php echo date("Y")-[date-field format="Y"]-( date("nd") < [date-field format="nd"] ? 1 : 0 ); ?>{/source}{/article}