Calculating someone's age by comparing DOB in a recordset with current date and display it in years and months?
Is this complicated? I've found some functions online but none of them use a recordset value, they assume a static value.
This, for example:
<?php
//date in mm/dd/yyyy format; or it can be in other formats as well
$birthDate = "12/17/1983";
//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 "Age is:" . $age;
?>
I changed to this...
<?php
//date in mm/dd/yyyy format; or it can be in other formats as well
$birthDate = $rsPROFILE->getColumnVal("dogsdob");
//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 $age;
?>
..but all it does is display "2016".
Could anyone point me in the direction of a decent function for this that can handle UK date formats?
Thank you.
NJ