1
votes

I am using a customized version of fullCalendar. I would like my initial display and page reloads to display the following month. So the current month is March, when I bring up the calendar I would like to see April as the default month. I see this block of code.

var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var options = {
    weekday: "long", year: "numeric", month: "short",
    day: "numeric", hour: "2-digit", minute: "2-digit"
};

I tried to change the third line var m = date.getMonth(); to var m = (date.getMonth()+ 1);

This had no affect. I am out of my element here. Any help would be appreciated greatly.

John

1

1 Answers

1
votes

If you want to set the date immediately when the calendar loads, then you can use the defaultDate option within your calendar setup options. Since fullCalendar uses momentJS, you can also use momentJS to really easily, dynamically select the current month +1, e.g.

$('#calendar').fullCalendar({
    defaultView: 'month',
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    defaultDate: moment().add(1, 'month')
});

See http://jsfiddle.net/sbxpv25p/306/ for a working demo.

See https://fullcalendar.io/docs/defaultDate and http://momentjs.com/docs/#/manipulating/add/ for more details