Copy CodeThe code is as follows:
function Getagebyid ($id) {
After this year's birthday is more than 1 years old
if (empty ($id)) return ';
$date =strtotime (substr ($id, 6,8));
Time stamp for Birth date
$today =strtotime (' Today ');
Get today's timestamp
$diff =floor (($today-$date)/86400/365);
Get a two-day difference in the number of years
Strtotime Plus this number of years to get that day after the timestamp compared to the time stamp of today
$age =strtotime (substr ($id, 6,8). ' + '. $diff. ' Years ') > $today? ($diff + 1): $diff;
return $age;
}
?>
http://www.bkjia.com/PHPjc/714950.html www.bkjia.com true http://www.bkjia.com/PHPjc/714950.html techarticle Copy the code as follows: Php function Getagebyid ($id) {//After this year's birthday is more than 1 years old if (empty ($id)) return "; $date =strtotime (substr ($id, 6,8 )); Get Birth date ...