So I have spent quite a bit of time researching how best to add recurring events to my calendar application.
I would like to use the PHP DateInterval function and have formulated the code below to try and work out how to create a recurring event based on the original events
EndDate of Recurrence
//user defined event start and finish dates
$eventStart = new DateTime( '2011-01-31 09:00:00' );
$eventFinish = new DateTime( '2011-01-32 17:00:00' );
//user defined event recurring end date
$endRecurring = new DateTime( '2011-05-31 23:59:59' );
//define for recurring period function
$begin = $eventStart;
$end = $endRecurring;
//define our interval
$interval = DateInterval::createFromDateString('next friday');
$period = new DatePeriod($begin, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
//loop through and create new dates for recurring events
foreach ( $period as $dt )
$recurringStartDate = $dt->format( "l Y-m-d H:i:s\n" );
$recurringEndDate = ?NOT SURE HOW TO PROCESS THE END DATE IN THIS START DATE FOREACH LOOP?
Repeat every Monday, Wednesday and Friday
There is a Date/Calendar recursion library for PHP 5.2+ by Thomas Planer. Its not DateInterval, but it seems to do the trick. Check it out at https://github.com/tplaner/When
I know this is an old question, but perhaps someone will benefit!