PHP 获取两个月之间的中间月

        $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);

猜你喜欢

转载自blog.csdn.net/qq_24909089/article/details/79852405