I am attempting to implement a Bootstrap calendar feature where cells are colored green if the timestamp is greater than today's date.
This can be achieved by:
$checkTime > $today
cell.css = green background
I came across this code snippet on Stack Overflow:
dayRender: function (date, cell) {
var today = new Date();
if (date.getDate() === today.getDate()) {
cell.css("background-color", "red");
}
}
I attempted to include it after:
defaultView: 'month',
resulting in:
defaultView: 'month',
dayRender: function (date, cell) {
var today = new Date();
if (date.getDate() === today.getDate()) {
cell.css("background-color", "red");
}
},
However, adding the dayRender function caused the calendar to not display properly.
Here is my full calendar implementation:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '<?php echo $today;?>',
defaultView: 'month',
editable: false,
events: [
<?php echo $calendar_html;?>
],
eventClick: function(event) {
if (event.url) {
window.open(event.url);
return false;
}
}
});
});