PHP 计算Date类型的差值

来源:互联网 发布:c语言编程经典例题 编辑:程序博客网 时间:2024/05/30 23:04
<?phpclass timeDiffer{    function getTimeDiffer($startdate){$enddate=date('Y-m-d H:i:s',time());$date=floor((strtotime($enddate)-strtotime($startdate))/86400);          $hour=floor(((strtotime($enddate)-strtotime($startdate))%86400)/3600%24);          $minute=floor(((strtotime($enddate)-strtotime($startdate))%86400)/60%60);          $second=floor((strtotime($enddate)-strtotime($startdate))%86400%60);$differTime = "";if((!empty($date))||$date!=null||$date!=0){$differTime =$differTime.$date."天";}if((!empty($hour))||$hour!=null||$hour!=0){$differTime =$differTime.$hour."小时";}if((!empty($minute))||$minute!=null||$minute!=0){$differTime =$differTime.$minute."分钟";}                if((!empty($second))||$second!=null||$second!=0){$differTime =$differTime.$second."分钟";}                // echo $date."天<br>";                // echo $hour."小时<br>";                // echo $minute."分钟<br>";                // echo $second."秒<br>";                return $differTime;     }}?>


1 0
原创粉丝点击