If I have a site where a person can add an event. I want them to be able to add an event and click a button which would add the event for the rest of the year on that day of the week or that date monthly. So if they enter a date that an event starts for like 02/14/2006 I would like to automatically add entries in the database for 02/21/2006 02/28/2006 etc for weekly and 03/14/2006 and 04/14/2006 for monthly etc. Any idea how to go about doing this, I would just add the take the 14 and add 7 but when the month was over and I had to go into March how would I go about doing that?
Thanks for all help, it's truely appreciated.
when using mktime() you can add/subtract any number from each of the values.
e.g. you can add the next 3 years of month like this:
for ($mth=0;$mth<=36;%mth++) { $date=date("Ymd",mktime(0,0,0,date("m")+$mth,date("j"),date("Y"))); //blah }
Thank you, that works great for a month, how about if I want to add something for every week?
Thanks in advance.
For weekly items (or daily/weekly):
[man]strtotime/man: Every week: $date = strtotime("+1 week", $date); Every day: $date = strtotime("+1 day", $date);
Then, just loop through from start date to end date.
~Brett