Home  >  Article  >  Backend Development  >  PHP求周岁

PHP求周岁

WBOY
WBOYOriginal
2016-06-20 12:43:22926browse

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);
        }
    }
    $age = date('Y') - $year;
    if (date('m')     return $age;
}


    /**
     * 计算年龄
     * @param $args
     * @return number:返回当前年龄
     */
    private function getAge($birthyear,$birthday){
        $year = date("Y");
        $date = date('md');
        $add_age = $birthday         $age = $year - $birthyear + $add_age;
        if($age             $age = 18;
        }
        return $age;
    }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn