色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

PHP 年齡計(jì)算函數(shù)(精確到天)

復(fù)制代碼 代碼如下:
<?php
/**
* php 年齡計(jì)算函數(shù)
*
* 參數(shù)支持?jǐn)?shù)組傳參和標(biāo)準(zhǔn)的 Mysql date 類型傳參
* params sample
* --------------------------------------------------
$birthArr = array(
'year' => '2000',
'month' => '11',
'day' => '3'
);
$birthStr = '2000-11-03';
* --------------------------------------------------
* );
* @author IT不倒翁 <itbudaoweng@gmail.com>
* @copyright (c) 2011,2012 Just Use It!
* @link IT不倒翁 http://yungbo.com
* @param string|array $birthday
* @return number $age
*/
function getAge($birthday) {
$age = 0;
$year = $month = $day = 0;
if (is_array($birthday)) {
extract($birthday);
} else {
if (strpos($birthday, '-') !== false) {
list($year, $month, $day) = explode('-', $birthday);
$day = substr($day, 0, 2); //get the first two chars in case of '2000-11-03 12:12:00'
}
}
$age = date('Y') - $year;
if (date('m') < $month || (date('m') == $month && date('d') < $day)) $age--;
return $age;
}

php技術(shù)PHP 年齡計(jì)算函數(shù)(精確到天),轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 信宜市| 大厂| 洞头县| 仁寿县| 正镶白旗| 安国市| 屯留县| 庆云县| 隆回县| 高青县| 红桥区| 乐业县| 陈巴尔虎旗| 珲春市| 永善县| 丰镇市| 昆山市| 双峰县| 奉节县| 当阳市| 长宁县| 伽师县| 且末县| 吉木萨尔县| 黑山县| 教育| 大理市| 沈丘县| 光山县| 南投市| 西华县| 博野县| 临高县| 刚察县| 侯马市| 高淳县| 肥西县| 嵊州市| 应城市| 宁国市| 中牟县|