PHP根據生日計算年齡(週歲)
<?php/** * 根据时间戳计算年龄 * @param $birth * @return mixed */functionhowOld($birth) {list($birthYear, $birthMonth, $birthDay) = explode('-', date('Y-m-d', $birth)); list($currentYear, $currentMonth, $currentDay) = explode('-', date('Y-m-d')); $age = $currentYear - $birthYear - 1; if($currentMonth > $birthMonth || $currentMonth == $birthMonth && $currentDay >= $birthDay) $age++; return$age; } ?>
以上介紹了PHP根據生日計算年齡(週歲),包括了方面的內容,更多相關內容請關注PHPcn網絡(www.php.cn) !
相關文章: