Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Snapey's avatar
Level 122

Repeating calendar entries

I'm looking for some ideas / resources to help me design a repeating entry function.

I have an application that has events. These events have other properties such as the date, shifts, and resources. My customers are asking for a repeat function. For instance, the event should re-occur every Saturday.

Should I go ahead and create entries in the model for future dates (if so then for how long!) or should I create them a bit more on the fly? Show like a templated event for any given future date and then only create it in the database if someone actually modifies it?

suggestions welcome!

0 likes
10 replies
jlrdw's avatar

I do a site for a humane society, and really I have never heard of an exact same event reoccurring that often so I would let the user enter the event they want in the database, and display it accordingly. That way end user has all control on that events slot, you never know when changes are going to happen. Someone could be sick one Sunday for example.

Snapey's avatar
Level 122

The user will create a rota to man a charity shop for instance. They know that every week they need certain roles filling and want to put up a calendar for people to fill in their names as to what jobs they can do. It will be the same requirement week after week - like an empty rota.

jlrdw's avatar

Have the event as a one to many, one event with many workers. That would make it easy to for each through it in a table if they wanted to print it out and give everyone a copy. But I would still have a way for the database user to enter an alternate event in case of rain, a sickness, or whatever.
Edit: you got me on the rota word, I had to look that up.

cmtiffani's avatar

I manage several sites for churches and such that have event calendars with repeating events. They want to be able to enter service times for example, and not have to add a new event for every Sunday morning from here till the rapture.

What I currently do is record a single event with 'repeating' properties, so there are settings for the repeat_interval (weekly, monthly, never), repeat_period (every x weeks/months), start_datetime, end_datetime. That's managed through a backend CMS by the client. The front end of the website uses the repeating properties to generate the calendar, typically for a given month, or to suit the view the front end visitor needs to see.

Because this has also come up, if they have an exception to the repeating rule, then it's not repeating. For my sanity repeating = identical. I tell them to stop the repeating before the anomaly, add a one-time event for the oddball instance, and then create another repeating event to carry on after the anomaly.

I know this is a a couple of months old, but maybe it's still useful

Snapey's avatar
Level 122

thanks @cmtiffani . I have not implemented this yet so still open to suggestions.

Taking your scenario as an example, suppose the church wanted to note the name of someone to arrange the flowers for each of the future events. At this point, the repeating event now becomes a unique event since one service now has unique properties.

My thought is to have the calendar show the repeat, and as soon as someone adds something to the event the details of the repeater are converted to a standalone instance.

The trick is in the calendar to list the events and know that a unique event supercedes a repeater.

cmtiffani's avatar

@snapey - yeah, that does make it more awkward adding in the people per event component.

I think you're right: use the repeater to create a unique event that can overwrite a single instance. Add a reference field on the unique entry that references the repeat entry. Before you start iterating over the repeat, grab any uniques that also match that reference field. Then when you're iterating over the repeats you just need to check if a unique entry exists for that date iteration and use that data instead. Otherwise, fallback to your default repeat data.

You'll still have to test for stupids - if the client changes the start date from a Sun to a Tue for example, the repeating dates for your unique instances may not match up.

Oh, and as for the 'how long do you let it repeat for' part of the question: I always make them put an end date, even if that's 30 years in the future, but you could probably just as easily leave it open ended, especially if you're not creating an event per recurrence unless it has unique info, which they have to do manually.

1 like
jekinney's avatar

I use the google calendar API. Which does all the heavy lifting for you including repeating events.

Please or to participate in this conversation.