如何使用PHP计算两个日期之间的差异?
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我有两个日期格式: Start Date: 2007-03-24 End Date: 2009-06-26 现在,我需要以以下形式查找这两者之间的区别: 2 years, 3 months and 2 days 如何在PHP中做到这一点? #1楼 前段时间,我编写了 format_date 函数,因为它为 您 提供 了如何选择日期的许多选项 : function format_date($date, $type, $seperator="-") { if($date) { $day = date("j", strtotime($date)); $month = date("n", strtotime($date)); $year = date("Y", strtotime($date)); $hour = date("H", strtotime($date)); $min = date("i", strtotime($date)); $sec = date("s", strtotime($date)); switch($type) { case 0: $date = date("Y".$seperator."m".$seperator."d",mktime($hour, $min, $sec, $month,