javascriptcalendarfullcalendarfullcalendar-4

Full calendar 4.0 event displayed in 2 days in month mode if the start time is in between 22:00 to 24:00


In full calendar 4.0, an event with the time : "start":"2020-JULY-09 23:40", occupies 2 cells july-08 and July-9th in month mode as in the attached image and in Day mode also the events in the previous day those are in between the time 22:00 to 24:00 are displayed in the next day 12:00 AM . How can we avoid this particularly in month mode, I even tried with start and end also, one of the forum suggested using eventsfterrender we can achieve this and this is a feature of fullcalendar. Please suggest.

enter image description here


Solution

  • You said

    event with the time : "start":"2020-JULY-09 23:40"

    and

    those are in between the time 22:00 to 24:00

    are being shown on the following day as well.

    From what you've written it sounds like these events don't have defined end dates/times.

    If you don't specify an end date, then fullCalendar will give your events a standard length (or duration) of time. As per https://fullcalendar.io/docs/defaultTimedEventDuration this time is set as 1 hour by default.

    Hence any event with a start date of 23:00 or later would have a default end time which goes into the next day. (I'm not sure about the ones you say "from 22:00" - did you mean "23:00" perhaps?)

    So to avoid this you can either change the defaultTimeEventDuration, or of course if you set specific end dates, you have a lot more control over the length of your events. (You already mentioned "I tried with start and end also" but unfortunately from your description it's not clear in that case what precisely you tried and what the effect was. However it will be possible to alter the behaviour if you want to, by adding end dates.)