MySQL查询生日是今天的用户
select * from customer where MONTH(birthday) = MONTH(NOW()) and DAY(birthday) = DAY(NOW())
查询7天内生日的用户
select * from customer
where DATE_FORMAT(birthday,'%m-%d') >= DATE_FORMAT(now(),'%m-%d')
and DATE_FORMAT(birthday,'%m-%d')
PHP从身份证号中获取生日的方法
$birth = date('Y-m-d',strtotime(substr($idNum, 6, 8)));
$生日 = strlen($身份证号)==15 ? ('19' . substr($身份证号, 6, 6)) : substr($身份证号, 6, 8); $性别 = substr($身份证号, (strlen($身份证号)==15 ? -2 : -1), 1) % 2 ? '男' : '女';