1.时间:$start_time = $_GET[‘start_time‘]; //2015-01$end_time = $_GET[‘end_time‘]; //2015-052.对时间进行拆分:$time[‘start_time‘] = explode(‘-‘, $start_time);$time[‘end_time‘] = explode(‘-‘, $end_time); $j = $time[‘end_time‘][0] - $time[‘start_time‘][0]; //得到开始月$year1 = $time[‘start_time‘][0];$time1 = array();$k = 1;for ($i = $time[‘start_time‘][1]; $i <= $time[‘end_time‘][1] + $j * 12; $i++) { if (!($i % 12)) $moth1 = 12; else $moth1 = $i % 12; $data = date(‘Y-m‘, strtotime($year1 . "-" . $moth1)); $non = $year1 . $moth1; $time1[$k++] = $non; if (!($i % 12)) $year1++;}得到结果 :2015-01 2015-02 2015-03 2015-04 2015-05
时间: 2024-10-20 01:05:58