Copy code The code is as follows:
/**
* Generate a month array from the start month to the end month
* This method is modeled after Dang Zihao’s getDateArr() method
* @param unknown_type $start
* @param unknown_type $end
*/
function getMonthArr($start, $end)
{
$start = empty($start) ? date('Y-m',strtotime('-1 month')) : $start;
$end = empty($end) ? date( 'Y-m') : $end;
//Convert to timestamp
$st = strtotime($start.'-01');
$et = strtotime($end. '-01');
$t = $st;
$i = 0;
while($t <= $et)
{
//Accumulate here The calculation formula for the total number of seconds in each month: the timestamp seconds on the 1st of the previous month minus the timestamp seconds of the current month
//I don’t understand what I want to say
$d[$i] = trim(date('Y-m',$t),' ');
$t += strtotime('+1 month', $t)-$t;
$i++;
}
return $d;
}
http://www.bkjia.com/PHPjc/325458.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325458.htmlTechArticleCopy code The code is as follows: /** * Generate a month array from the starting month to the ending month* This method is modeled after the party Zihao getDateArr() method * @param unknown_type $start * @param unknown_type...