- /**
- * 判断两日期是不是同一周
- * 星期是按周日到周六
- */
- functiongetSameWeek($pretime,$aftertime){
- $flag= false;//默认不是同一周
- $afweek=date('w',$aftertime);//当前是星期几
- $mintime=$aftertime-$afweek* 3600*24;//一周开始时间
- $maxtime=$aftertime+ (7-$afweek)*3600*24;//一周结束时间
- if($pretime>=$mintime&&$pretime<=$maxtime){//同一周
- $flag= true;
- }
- return$flag;
- }
- $testWeek_start=strtotime('2017-8-19');
- $testWeek_end=strtotime('2017-8-23');
- echogetSameWeek($testWeek_start,$testWeek_end)?'在同一周':'不在同一周';
新闻热点
疑难解答