//获取前6个月月份
public function to_sex_month(){
$today = input('param.today') ? input('param.today') : date("Y-m-d");
$arr = array();
$old_time = strtotime('-6 month',strtotime($today));
for($i = 0;$i <= 6; ++$i){
$t = strtotime("+$i month",$old_time);
$arr[]=date('Y-m',$t);
}
return $arr;
}
//获取前6天日期
public function to_sex_day(){
$today = input('param.today') ? input('param.today') : date("Y-m-d");
$arr = array();
$old_time = strtotime('-6 day',strtotime($today));
for($i = 0;$i <= 6; ++$i){
$t = strtotime("+$i day",$old_time);
$arr[]=date('Y-m-d',$t);
}
return $arr;
}
来源:https://www.cnblogs.com/houdj/p/11211181.html