//先取开始日期所处的星期,然后计算时间段内有几个星期
$n = (strtotime($enddate)-strtotime($startdate))/86400;
//$endDate = date("Y-m-d",strtotime("$endDate +1 day"));
if($n<=7){
$day = date("w",strtotime($startdate))-1;
$week_start = date("Y-m-d 00:00:00",strtotime("$startdate -{$day} day"));
$day = 7-$day;
$week_end = date("Y-m-d 00:00:00",strtotime("$startdate +{$day} day"));
if($week_end >= $enddate){
$weekList[] =array($startdate,$enddate);
}else{
$weekList[] =array($startdate,$week_end);
$weekList[] =array($week_end,$enddate);
}
}else{
$day = date("w",strtotime($startdate))-1;
$week_start = date("Y-m-d 00:00:00",strtotime("$startdate -{$day} day"));
$day = 7-$day;
$week_end = date("Y-m-d 00:00:00",strtotime("$startdate +{$day} day"));
$weekList[] =array($startdate,$week_end);
if($week_end >= $enddate){
$weekList[] = array($week_end,$enddate);
}else{
while($week_end <= $enddate){
$start = $week_end;
$week_end = date("Y-m-d 00:00:00",strtotime("$week_end +7 day"));
if($week_end <= $enddate){
$weekList[] = array($start,$week_end);
}else{
$weekList[] = array($start,$enddate);
}
}
}
}
$month = date("Y-m",strtotime($startdate));
//月份第一天的日期
$first_date=$month.'-01';
//月份的天数
$count_days=date("t",strtotime($month));
//月份最后一天的日期
$last_date=date("Y-m-d 00:00:00",strtotime($first_date.($count_days-1)." day"));
if($enddate <= $last_date){
$month_list[] = array($startdate,$enddate);
}else{
$month_list[] = array($startdate,$last_date);
while($enddate > $last_date){
//下个月的第一天
$next_first_day = date("Y-m-d 00:00:00",strtotime($last_date."+1 day"));
//下个月月份
$next_month = date("Y-m",strtotime($next_first_day));
//下月月份的天数
$next_count_days=date("t",strtotime($next_month));
//下个月的最后一天
$last_date = date("Y-m-d 00:00:00",strtotime($next_first_day.($next_count_days-1)." day"));
if($enddate < $last_date){
$month_list[] = array($next_first_day,$enddate);
}else{
$month_list[] = array($next_first_day,$last_date);
}
}
}
vue2 Implicit conversion from float int loses precision php8Implicit Mysql8新增用户,mysql8配置权限,mysql8配置,mysql8配置文件 Linux命令,scp,scp命令,Linux复制 git commit git add centos git 搭建FTP,Linux FTP,禁止FTP登录ssh 上传文件,阿里云OSS上传,文件上传到OSS,OSS文件上传,OSS上传 微信支付,微信支付V3,PHP微信支付,微信nativePay支付,微信jsapi支付 微信支付,微信支付V3,PHP微信支付 bootstrap4 modal, lavarel The subversion command line tools are no longer provided by Xcode. 银联支付,tp5.1银联支付 支付宝即时到账,PHP支付宝 system libzip must be upgraded to version >= 0.11 CMake 3.0.2 or higher is required