The content of this article is to share with you PHP to obtain the intermediate month code between two months. Friends in need can refer to it
$time1 = strtotime('2014-10-04'); //开始日期 $time2 = strtotime('2015-02-06'); //结束日期 $month = array(); //定义数组 $month[] = date('Y-m',$time1); while( ($time1 = strtotime('+1 month', $time1)) <= $time2){ $month[] = date('Y-m',$time1); // 取得递增月; } print_r($month);
The above is the detailed content of PHP Get the middle month between two months. For more information, please follow other related articles on the PHP Chinese website!