Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $year=date('Y');
- $from = new DateTime($year.'-09-01 08:00:00');
- $to = new DateTime($year.'-09-01 21:00:00');
- $to->modify('+52 week');
- $period = new DatePeriod($from, new DateInterval('P1D'), $to);
- $period=iterator_to_array($period);
- $aWeek=array();
- $start=false;
- for($i=0,$size=sizeof($period);$i<$size;++$i){
- $w=$period[$i]->format('w');
- $d[]=$period[$i]->format('Y-m-d H:i:s');
- if(!$start)$start=$period[$i]->format('Y-m-d H:i:s');
- if($w==0)$end=$period[$i]->format('Y-m-d H:i:s');
- if($start && $end){
- $aWeek[]=['r'=>array($start,$end),'d'=>$d];
- unset($start,$end,$d);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement