开发者

How do I determine the start and end date on the agendaWeek view in FullCalendar?

开发者 https://www.devze.com 2023-03-18 16:23 出处:网络
I\'m customizing the width and position of the events my FullCalendar with agendaWeek as the view. I need to know what the start and end dates are of the week.

I'm customizing the width and position of the events my FullCalendar with agendaWeek as the view. I need to know what the start and end dates are of the week.

I know I can use $('#calendar').fullCalendar('getDate') to get the c开发者_运维问答urrent date and I could figure out the day of the week and calculate the start/end dates, but I'm hoping and assuming there is a property that I can read.


If you're getting your events from a file, FullCalendar posts the start and end dates for the current week view. Take a look at this page from the official documentation: http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/

If you call FullCalendar like this:

$('#calendar').fullCalendar({
    events: '/myfeed.php'
});

The URL it will use includes a query string with the start and end UNIX timestamps:

/myfeed.php?start=1262332800&end=1265011200&_=1263178646

Note: The _ parameter is automatically inserted to prevent the browser from caching the result.

If you're generating you events by function, it similiarly provides the start and end times, but they are JavaScript Date objects. See this page from the official documentation: http://arshaw.com/fullcalendar/docs/event_data/events_function/

$('#calendar').fullCalendar({
    events: function(start, end, callback) {
       //Manipulate the start and end objects
    }
});

If you're just supplying an array of event dates (as per http://arshaw.com/fullcalendar/docs/event_data/events_array/), the start and end dates are not accessible. You will need to use one of the two methods above.


You can get the start date using :

$('#calendar').fullCalendar('getView').start._i

Then just add up the days in the week to get your end date

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号