| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | 
							- <?php
 
- class DateUtil {
 
-     /**
 
-      * 获取某个时间段内所有月份 (包含开头结尾月份)
 
-      * @param minDate
 
-      * @param maxDate
 
-      * @return
 
-      * @throws ParseException
 
-      */
 
-     public static function getMonthBetweenDates($minDate, $maxDate) {
 
-         $sTime = strtotime(date('Y-m-01', strtotime($minDate)));
 
-         $eTime = strtotime(date('Y-m-01', strtotime($maxDate)));
 
-         $months = [];
 
-         while ($sTime <= $eTime) {
 
-             $months[] = date('Y-m', $sTime);
 
-             $sTime = strtotime('next month', $sTime);
 
-         }
 
-         return $months;
 
-     }
 
-     /**
 
-      * 获取某个时间段内所有月份 (包含开头月份,不包含结尾月份)
 
-      * @param minDate
 
-      * @param maxDate
 
-      * @return
 
-      * @throws ParseException
 
-      */
 
-     public static function getMonthBetweenDatesNotEnd($minDate, $maxDate) {
 
-         $sTime = strtotime(date('Y-m-01', strtotime($minDate)));
 
-         $eTime = strtotime(date('Y-m-01', strtotime($maxDate)));
 
-         $months = [];
 
-         while ($sTime < $eTime) {
 
-             $months[] = date('Y-m', $sTime);
 
-             $sTime = strtotime('next month', $sTime);
 
-         }
 
-         return $months;
 
-     }
 
-     /**
 
-      * 获取某个时间段内所有月份 (不包含开头月份,包含结尾月份)
 
-      * @param minDate
 
-      * @param maxDate
 
-      * @return
 
-      * @throws ParseException
 
-      */
 
-     public static function getMonthBetweenDatesNotBegin($minDate, $maxDate) {
 
-         $sTime = strtotime(date('Y-m-01', strtotime($minDate)));
 
-         $eTime = strtotime(date('Y-m-01', strtotime($maxDate)));
 
-         $months = [];
 
-         $sTime = strtotime("next month", $sTime); //第一个月跳过
 
-         while ($sTime <= $eTime) {
 
-             $months[] = date('Y-m', $sTime);
 
-             $sTime = strtotime('next month', $sTime);
 
-         }
 
-         return $months;
 
-     }
 
- }
 
 
  |