Copy code The code is as follows:
function getAgeByID($id){
/ / Only after this year’s birthday is one more year old
If(empty($id)) return '';
$date=strtotime(substr($id,6,8));
// Get the time stamp of the date of birth
$ TODAY = StrTotime ('TODAY');
// Get today's timestamp
$ Diff = Floor (($ today-$ date)/86400 /365);
//Get the approximate number of years between the two dates
//Add this number of years to strtotime to get the timestamp of that day and compare it with today’s timestamp
=strtotime(substr($id,6,8).' +'.$diff.'years')>$today?($diff+1):$diff;
Return $age;
}
?>
http://www.bkjia.com/PHPjc/714950.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/714950.htmlTechArticleCopy the code as follows: ?php function getAgeByID($id){ //It’s only after this year’s birthday 1 more year old if(empty($id)) return ''; $date=strtotime(substr($id,6,8)); //Get the date of birth...