Is there a way to create a calendar in PHP that starts with the current week (sunday) and goes for X weeks? Here is a design for reference, I like that the month is in the first column of the table. Instead of having lines speperating each month, I thought it may be easier to use different color shading for each cell that belongs to a particular month.
Here is some code that lays the groundwork by getting the current week and an array for 6 weeks out.
function getDatesFromRange($start,$end){
$dates = array($start);
while(end($dates) < $end){
$dates[] = date('Y-m-d',strtotime(end($dates).' +1 day'));
}
return $dates;
}
$current_date = '2018-01-28';
// check if current is sunday
$dayw = date('w',strtotime($current_date));
$start_date = $current_date;
if($dayw != 0){
$prev_sunday = date('Y-m-d',strtotime('last sunday '.$current_date));
$start_date = $prev_sunday;
}
$end_date = date('Y-m-d',strtotime('+6 weeks '.$start_date));
$date_ranges = getDatesFromRange($start_date,$end_date);
unset($date_ranges[41]);