-
//年
- $year = date("Y");
- $beninTime = mktime(0,0,0,1,1,$year);
- $endTime = mktime(0,0,0,1,1,$year+1)-1;
- $weekArray = array();
- $isBegin = true;
- $forTime = 0;
- for ($time=$beninTime;$time $forTime++;
- $start = $end = 0;
- if($isBegin){
- //$nIndex==1表示星期一,$nIndex==7表示星期日
- $nIndex = date("N",$time);
- //$mulNum=1表示过1天就是星期一,
- $mulNum = 0;
- switch ($nIndex){
- case 1: $mulNum =7; break;
- case 2: $mulNum =6; break;
- case 3: $mulNum =5; break;
- case 4: $mulNum =4; break;
- case 5: $mulNum =3; break;
- case 6: $mulNum =2; break;
- case 7: $mulNum =1; break;
- }
- }else{
- //周1
- $mulNum = 7;
- }
- if($mulNum>2){
- $start = $time;
- //周五时间
- $end = $time+($mulNum-2-1)*24*60*60;
- if($end>$endTime){
- $end = $endTime;
- }
- $weekArray[] = array(
- 'start'=>$start,
- 'end'=> $end,
- );
- if($end>=$endTime){
- break;
- }
- }
- $time += $mulNum*24*60*60;
- $isBegin = false;
- }
- echo $forTime.'
';
- foreach ($weekArray as $week){
- echo date("Y-m-d",$week['start'])."星期".date("N",$week['start']).">>>>>>".date("Y-m-d",$week['end'])."星期".date("N",$week['end']).'
';
- }
- ?>
复制代码
|
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31