bilimokur adlı üyeden alıntı

Stackoverflowda şöyle bir örnek var. Güzel çalışıyor.


//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;
?>


Buradan test edebilirsiniz. Konu linki.

Daha gelişmiş bir örnek içinse github örneği. Basit bir google araması ile karşıma çıkan sonuçlar :)


dediğiniz kodlama hocam 11/01/1991 27 yas olması lazım değil mi..

10/01/1991 de 28 olması lazım ama ikiside 27 gösteriyor