Skip to content

Instantly share code, notes, and snippets.

@mr-fan
Created August 26, 2015 18:58
Show Gist options
  • Save mr-fan/c89fcc57b2db94f443aa to your computer and use it in GitHub Desktop.
Save mr-fan/c89fcc57b2db94f443aa to your computer and use it in GitHub Desktop.
calendar function recurring events
$event_date = "2012-10-06";
$event_end_date = "2012-10-08";
$event_repetition_type = "Daily";
$date_calculation = "";
switch ($event_repetition_type) {
case "Daily":
$date_calculation = " +1 day";
break;
case "Weekly":
$date_calculation = " +1 week";
break;
case "Monthly":
$date_calculation = " +1 month";
break;
default:
$date_calculation = "none";
}
$dateArray[] = $event_date;
$day = strtotime($event_date);
$to = strtotime($event_end_date);
while( $day <= $to )
{
$day = strtotime(date("Y-m-d", $day) . $date_calculation);
$dateArray[] = date("Y-m-d" , $day);
}
//here make above array as key in $a array
$a = array_fill_keys($dateArray, 'none');
print_r($a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment