I am using this construct to insert weekly recurring events into a calendar:
switch ($recurring_type) {
case "weekly":
for( $i=0 ; $i < $recurring_duration ; $i++ ){
$insmonth = date("m" , $initial_time + $i*7*$SECONDS_PER_DAY);
$insday = date("d" , $initial_time + $i*7*$SECONDS_PER_DAY);
$insyear = date("Y" , $initial_time + $i*7*$SECONDS_PER_DAY);
//the db part: $query = "INSERT INTO ... bla bla
$msg .= "INSERT for " . date("M d Y",$initial_time + $i*7*$SECONDS_PER_DAY) . "<br>\n";
}
break;
}
This works fine, but for MONTHLY (say, 2nd Thursday) recurring events, $i47*$SECONDS_PER_DAY only works until there is a month with 5 Thursdays -- How would you loop to find these exceptions?
--OR-- would it be better to completely shift gears and pull new vars from the input form (if so, how):
1st
2nd
3rd
4th... weekday
Thanks,
--ph