I have a database of events that are "static" (on a specific day) and "repeating" (starting on a specific day, but are set to "repeating" every week or every other week). I understand that there should be intervals of 7 and 14, but I do not know how to get to this point to find the date> today and spit it out.
therefore an example;
I want to find the next upcoming recurring events and spit out their respective dates. Side note: the data I'm stuck in is in the lines (I know, I know) of Ymd, so 20150821 will be on August 21, 2015.
if today was August 21, 2015, and there is a recurring event for โevery other Fridayโ starting August 7, it would be +14, which will deliver you today, Friday, August 21.
But say that one of them "every Wednesday", starting from August 19, I want to get the date on Wednesday, August 26, and spit it out.
In the future, this will require endless dates, since start dates do not change.
So, by running the script on January 1, 2016, I will need to know that the next "Every Wednesday" was January 6, 2016.
pseudo code:
if(start_date < today_date) { // start date is in the past add recurring_inverval to start_date until result >= today_date echo result } elseif(start_date > today_date { // start date is in the future echo start_date }
this is the add up to x in which I got lost. Not sure how to do this in an if statement.
also not sure if this is the best way to do this. I know that PHP can also execute complex strings and convert them to a date. like "Next Saturday"