I'm trying to get this code to calculate the age from a field in a form.
<?php
$birthDate = "$dob";
$birthDate = explode("-", $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;
?>
but i can't get it to use the format of the input field which is YYYY-MM-DD.
If i change $dob to a date in the eu standard format that PHP uses it works like a charm.
Is there some easy way to correct this?