So I've got this much figured out:
Say my user has a calendar event that they want to schedule to occur every two weeks for the next two months. To figure out the first date after their initial start date, I've got this:
$date = date_create('2013-07-16');
date_add($date, date_interval_create_from_date_string('14 days'));
echo date_format($date, 'Y-m-d'); //the next date in the sequence
I've yet to create a loop that would insert the data, but I'm stuck as far as how I would create a script that first calculates the number of times I would loop through the data.
For example, I'm looking at this:
// Show event dates for next 2 years
// one year = ~52 weeks
// 52 weeks / 4 weeks intervals = 13 months ;)
// So, two years = 26 intervals with 4 weeks
//
for($i = 1; $i <= 26; $i++)
{
$weekOffset = $i * 4;
$nextDate = strtotime("{$startDate} +{$weekOffset} weeks");
echo date('Y-m-d l', $nextDate) . PHP_EOL.'<BR>';
}
But how do I do the computations that produce the $i variable based on the dates my user inputs as the start and end dates?
Thoughts?
Our community of experts have been thoroughly vetted for their expertise and industry experience.