/** * 計算兩個月份之間的月份 * * * * * 日期均爲2018-08格式 */ public function CalcMonths($start,$end){ $time1 = strtotime($start); // 自動爲00:00:00 時分秒 $time2 = strtotime($end); $monarr = array(); // $monarr[] = $start; // 當前月; $monarr[]=[ 'list'=>date('Y-m',$time1), ]; while( ($time1 = strtotime('+1 month', $time1)) <= $time2){ // $monarr[] = date('Y-m',$time1); // 取得遞增月; $monarr[]=[ 'list'=>date('Y-m',$time1), ]; } return $monarr; }