php计算年龄精准到年月日

这篇博客提供了一个PHP实例,展示了如何准确地计算一个人的年龄,精确到年月日。通过阅读,读者可以学习到具体的实现代码和输出结果。
摘要由CSDN通过智能技术生成
这篇文章主要介绍了php计算年龄精准到年月日的方法,涉及php操作日期与字符串的相关技巧,非常简单实用,需要的朋友可以参考下

  本文实例讲述了php计算年龄精准到年月日的方法。分享给大家供大家参考。具体如下:

<?php
   
/*
  * To change this license header, choose License Headers in Project Properties.
  * To change this template file, choose Tools | Templates
  * and open the template in the editor.
  */
   
class  Age {
     
   /**
    * 计算年龄精准到年月日
    * @param type $birthday
    * @return array
    */
   
   public  function  calAge( $birthday ) {
     list( $byear $bmonth $bday ) =  explode ( '-' $birthday );
     list( $year $month $day ) =  explode ( '-' date ( 'Y-m-d' ));
     $bmonth  intval ( $bmonth );
     $bday  intval ( $bday );
     if  ( $bmonth  < 10) {
       $bmonth  '0'  $bmonth ;
     }
     if  ( $bday  < 10) {
       $bday  '0'  $bday ;
     }
     $bi  intval ( $byear 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值