Home > Backend Development > PHP Tutorial > php 依据出生日期生成年龄

php 依据出生日期生成年龄

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:38:51
Original
1050 people have browsed it

php 根据出生日期生成年龄

<?php $birthday = '1985-02-01';$age = date('Y', time()) - date('Y', strtotime($birthday)) - 1;if (date('m', time()) == date('m', strtotime($birthday))){	if (date('d', time()) > date('d', strtotime($birthday))){	$age++;	}}elseif (date('m', time()) > date('m', strtotime($birthday))){	$age++;}echo $age;?>mysql 当前时间-n年计算select date_add(curdate(), interval -1 year);
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
Compare JavaScript Date objects
From 1970-01-01 08:00:00
0
0
0
Select rows grouped by date
From 1970-01-01 08:00:00
0
0
0
Hive query: Convert date timestamp to date format
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template