PHP获取两个日期之间所有月份


function
getMonthForDates($sDate, $eDate) { $sTime = strtotime(date('Y-m-01', strtotime($sDate))); $eTime = strtotime(date('Y-m-01', strtotime($eDate))); $months = []; while ($sTime <= $eTime) { $months[] = date('Y-m', $sTime); $sTime = strtotime('next month', $sTime); } return $months; }

 

posted @ 2022-04-25 10:48  抠脚码农  阅读(1141)  评论(0编辑  收藏  举报