PHP获取两个时间点之间所有的月份?
fourtwothree opened this issue · comments
FourTwoThree commented
private function getMonthArr($time1, $time2)
{
$time1 = strtotime($time1); //
$time2 = strtotime($time2);
$monthArr = array();
$monthArr[] = date('Y-m', $time1); // 当前月;
while(($time1 = strtotime('+1 month', $time1)) <= $time2){
$monthArr[] = date('Y-m',$time1); // 取得递增月;
}
return $monthArr;
}