Home  >  Article  >  Web Front-end  >  How can I create recurring events in FullCalendar that occur only on specific days of the week?

How can I create recurring events in FullCalendar that occur only on specific days of the week?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-20 16:33:26443browse

How can I create recurring events in FullCalendar that occur only on specific days of the week?

Recurring Events in FullCalendar

FullCalendar offers several options for handling recurring events, including by days. To create a recurring event that occurs only on certain days of the week, you can use the dow (day of week) array.

Simple Recurring Events:

For simple weekly recurring events, such as "Every Monday and Thursday from 10:00am to 02:00pm," you can use the following code:

events: [{
    title:"My repeating event",
    start: '10:00',
    end: '14:00',
    dow: [ 1, 4 ] // Repeat monday and thursday
}]

Add Restrictions:

To limit the recurrence to specific start and end dates, use the ranges array:

eventId  timeStart  timeEnd   dow    dateStart      dateEnd
     1      10:00    12:00  [1,4]  2015/03/01   2015/04/01  // Month of March
     1      10:00    12:00  [1,4]  2015/05/01   2015/06/01  // Month of May
     1      10:00    12:00  [1,4]  2016/01/01   2017/01/01  // Year of 2017

On the client-side, use eventRender to filter out events that fall outside the specified ranges:

eventRender: function(event){
    return (event.ranges.filter(function(range){ 
        return (event.start.isBefore(range.end) &&
                event.end.isAfter(range.start));

    }).length)>0;
}

Overnight:

For overnight events that span multiple days, simply set the end time to be greater than 24:00:

{
  start: '10:00', 
  end:   '27:00', 
  dow: [1]
}

The above is the detailed content of How can I create recurring events in FullCalendar that occur only on specific days of the week?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn