Possible Duplicate:
PHP calculate age
I'm trying to subtract the years and check the user's age. I keep getting 1969 for $user_birth, which I think the raw date can't be parsed.
$raw_birth = "01-19-1980";
$user_birth = date("Y", strtotime($raw_birth));
$today_date = date("Y", time());
echo $raw_birth."<br />".$today_date."<br />".$user_birth."<br />";
e开发者_高级运维cho $today_date-$user_birth;
Any ideas?
$year="1997";
$month="01";
$day="24";
$age=date("Y");
$age-= $year;
if(($month>=date("m")) && ($day>date("d"))) {
$age--;
}
This code calculates an accurate age of an user.
精彩评论