php根据出生日期获取年龄,生日数据类型为date型
来源:互联网 发布:人工智能 军民融合 编辑:程序博客网 时间:2024/05/18 00:50
<span style="font-size:18px;"><strong>function age($birthday){ $birthday = strtotime($birthday);//int strtotime ( string $time [, int $now ] ) $year = date('Y', $birthday); if(($month = (date('m') - date('m', $birthday))) < 0){$year++; }else if ($month == 0 && date('d') - date('d', $birthday) < 0){$year++; } return date('Y') - $year;}</strong></span>
此外还有一个相对简单的解决方法:需要把 生日 unix时间戳,然后得出当前的时间戳差,最后除以一年的时间戳
function age($birthday) { if (strtotime($birthday) > 0){ return (int)((time() - strtotime($birthday))/(86400 * 365)) .'岁'; }else{ return '-'; } }
0 0
- php根据出生日期获取年龄,生日数据类型为date型
- 根据出生日期Date 计算年龄
- 根据生日 获取年龄
- Excel表格中根据身份证号获取出生日期、生日、年龄、性别、工龄、退休龄
- MySQL根据生日获取年龄
- Java-根据身份证号获取年龄,性别,出生日期
- php根据出生日期计算年龄函数
- 根据出生日期计算年龄
- 根据出生日期得到年龄
- 根据出生日期计算年龄
- 根据出生日期计算出年龄
- IOS 根据身份证号码获取 年龄 生日 性别
- PHP根据生日计算年龄(周岁)
- php根据生日计算年龄的方法
- 根据身份证号,使用Java编写程序获取年龄、性别、出生日期
- 根据身份证号,使用Java编写程序获取年龄、性别、出生日期
- 根据数据库中的生日date字段算年龄
- sql 根据出生日期计算年龄
- Java 从Jar文件中动态加载类
- OpenNI+VS2010环境配置
- 最简单的基于librtmp的示例:发布H.264(H.264通过RTMP发布)
- 生成release版本的Android系统 --签名
- zookeeper 安装 windows环境
- php根据出生日期获取年龄,生日数据类型为date型
- Letter Combinations of a Phone Number -- leetcode
- opencv2鼠标选定感兴趣区域用反投影算法检测相似部分
- 如何处理超出 GL_MAX_TEXTURE_SIZE 的图片
- shell脚本抽取文本文件中指定字符串的方法:sed+grep方法、awk+grep方法(必要时可以联合sed以及grep)、grep+cut方法
- 信息系统项目管理师 下午论文应试策略
- Unity通过层级关系获取子物体
- Construct Binary Tree from Inorder and Postorder Traversal
- arcgis for js api导入eclipse错误