/**
* 生成从开始月份到结束月份的月份数组
* 该方法仿照党子皓getDateArr()方法
* @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;
//转为时间戳
$st = strtotime($start.'-01');
$et = strtotime($end.'-01');
$t = $st;
$i = 0;
while($t {
//这里累加每个月的的总秒数 计算公式:上一月1号的时间戳秒数减去当前月的时间戳秒数
//看不懂自己想去
$d[$i] = trim(date('Y-m',$t),' ');
$t += strtotime('+1 month', $t)-$t;
$i++;
}
return $d;
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn