获取两个日期相差几年几月几日
/**
* 获取两个日期相差几年几月几日
* @param string $startDate [开始日期,如:2018-02-10 10:00]
* @param string $endDate [结束日期,如:2018-03-01 15:00]
* @throws Exception
*/
function workDate(string $startDate='2019-02-14 15:04:48'): string
{
$startTime = new DateTime($startDate);
$endTime = new DateTime();
$dateDifference=$startTime->diff($endTime);
return $dateDifference->format('博客已平稳运行 %y 年 %m 个月 %d 天');
}