这是我目前正在使用的代码,但它不起作用。Geboortedatum 在荷兰语中是生日的意思。
mysql_connect('xxx', 'xxx', 'xxx');
mysql_select_db('xxx');
$result = mysql_query("select Geboortedatum from Personen");
while ($row = mysql_fetch_array($result)){
$datum= $row["Geboortedatum"];
}
//date in mm/dd/yyyy format; or it can be in other formats as well
$birthDate = $datum;
echo $birthDate;
//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;
?>