计算两个时间相差几个月
//计算相差几个月 public function get_month_diff($start,$end) { $start = date('Y-m-d',$start); $end = date('Y-m-d',$end); $new_start = new \DateTime($start); $new_end = new \DateTime($end); $interval = \DateInterval::createFromDateString('1 month'); $period = new \DatePeriod($new_start, $interval, $new_end); $month = []; foreach ($period as $dt) { $month[] = $dt->format("Y-m"); } return count($month); }