Full calendar - week view - date and time highlight

356 Views Asked by At

How can I highlight specific dates with time in fullCalendar's week view?

In the month view the same result can be achieved using this code:

$('.fc-day[data-date="' + date + '"]').css("background-color", "rgba(143,223,130,0.5)");

In the week view click we need to highlight selected dates.

1

There are 1 best solutions below

0
Yusuf Ganiyu On

The question is not so clear but if I get your clearly, you're trying to highlight a week using CSS in the calendar. You can try something like this. It should work.

var startDate = '2023-04-02T00:00:00';
var endDate = '2023-04-06T00:00:00';

$('#calendar').fullCalendar({
  defaultView: 'agendaWeek',
  dayRender: function(date, cell) {
    if (date.isBetween(startDate, endDate, null, '[]')) {
      $(cell).css('background-color', 'rgba(143,223,130,0.5)');
    }
  }
});