国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php簡單計算年齡的方法(周歲與虛歲)

2024-05-04 23:53:18
字體:
來源:轉載
供稿:網友

本文實例講述了php簡單計算年齡的方法。分享給大家供大家參考,具體如下:

/*** $date是時間戳* $type為1的時候是虛歲,2的時候是周歲*/function getAgeByBirth($date,$type = 1){   $nowYear = date("Y",time());   $nowMonth = date("m",time());   $nowDay = date("d",time());   $birthYear = date("Y",$date);   $birthMonth = date("m",$date);   $birthDay = date("d",$date);   if($type == 1){    $age = $nowYear - ($birthYear - 1);   }else{$type == 2}{    if($nowMonth<$birthMonth){     $age = $nowYear - $birthYear - 1;    }elseif($nowMonth==$birthMonth){     if($nowDay<$birthDay){      $age = $nowYear - $birthYear - 1;     }else{      $age = $nowYear - $birthYear;     }    }else{     $age = $nowYear - $birthYear;    }   }   return $age;}

希望本文所述對大家PHP程序設計有所幫助。


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 任丘市| 玛曲县| 贵州省| 新邵县| 兴业县| 资溪县| 桂林市| 武功县| 深水埗区| 静宁县| 分宜县| 延庆县| 万全县| 崇礼县| 广平县| 麻栗坡县| 乐清市| 裕民县| 甘德县| 兰考县| 望奎县| 扶绥县| 卢氏县| 临泉县| 定兴县| 栾城县| 盘锦市| 拜城县| 美姑县| 乌拉特中旗| 若尔盖县| 石台县| 南开区| 南城县| 炉霍县| 枣强县| 囊谦县| 呼伦贝尔市| 五河县| 揭阳市| 莎车县|