I have a code which calculates the age but I need some modification on this one:
<?php
//date in mm/dd/yyyy format; or it can be in other formats as well
$birthDate = $tk_image_geboortedag ."-". $tk_image_geboortemaand ."-". $tk_image_geboortejaar;
//explode the date to get month, day and year
$birthDate = explode("-", $birthDate);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
? ((date("Y") - $birthDate[2]) - 1)
: (date("Y") - $birthDate[2]));
echo "Huidige leeftijd: " . $age;
?>
Now it returns: Huidige leeftijd: 19 (whatever it calculates).
What is need is; If the age is below 2 years I need to display the amount of months. So if the birthdate is 09-11-2016 it must show 12 months and if the amount of months is higher then 23 then show the age in years.
Can someone help me with this?
Regards, Robert