I would like to set the initial month to an arbitrary month when I call the function to display the calendar.
Say for example the user selects a date last june (June 2011) somewhere else and I want fullcalendar to show up with a month display of April before (April 2010). And yes, this is just to make a case, not to make sense ;-) )
I tried to call 'gotodate' before I then subsequently call the display function but this doesn't seem to work
$('#calendar').fullCalendar( 'gotoDate', currentdate); $('#calendar').fullCalendar({ header: {left: 'prevYear,prev,today,next,nextYear', center: 'title', right: 'month,basicWeek,basicDay' etc...}
Could someone eventually please provide an example how to do this properly?
You can try the following thread's solution(dayClick or select function to disable the dayclick for the past dates in fullcalendar). You can visit the fullcalendar support center and post your fullcalendar question on the StackOverflow fullcalendar tag.
You should use the options 'year', 'month', and 'date' when initializing to specify the initial date value used by fullcalendar:
$('#calendar').fullCalendar({ year: 2012, month: 4, date: 25 }); // This will initialize for May 25th, 2012.
See the function setYMD(date,y,m,d)
in the fullcalendar.js
file; note that the JavaScript setMonth, setDate, and setFullYear functions are used, so your month value needs to be 0-based (Jan is 0).
UPDATE: As others have noted in the comments, the correct way now (V3 as of writing this edit) is to initialize the defaultDate property to a value that is
anything the Moment constructor accepts, including an ISO8601 date string like "2014-02-01"
as it uses Moment.js. Documentation here.
Updated example:
$('#calendar').fullCalendar({ defaultDate: "2012-05-25" }); // This will initialize for May 25th, 2012.
You have it backwards. Display the calendar first, and then call gotoDate
.
$('#calendar').fullCalendar({ // Options }); $('#calendar').fullCalendar('gotoDate', currentDate);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With