如何在FullCalendar中的agendaWeek视图中确定开始日期和结束日期?

我正在使用agendaWeek作为视图自定义事件的宽度和位置。 我需要知道本周的开始和结束日期。

我知道我可以使用$(’#calendar’)。fullCalendar(’getDate’)来获取当前日期,我可以计算出星期几并计算开始/结束日期,但我希望并假设在那里是我可以阅读的财产。

如果您从文件中获取事件,FullCalendar会发布当前周视图的开始和结束日期。 从官方文档中查看此页面: http : //arshaw.com/fullcalendar/docs/event_data/events_json_feed/

如果您像这样调用FullCalendar:

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

它将使用的URL包括一个带有开始和结束UNIX时间戳的查询字符串:

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

注意:会自动插入_参数以防止浏览器缓存结果。

如果您按function生成事件,它类似地提供开始和结束时间,但它们是JavaScript Date对象。 从官方文档中查看此页面: http : //arshaw.com/fullcalendar/docs/event_data/events_function/

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

如果您只提供一系列事件日期(根据http://arshaw.com/fullcalendar/docs/event_data/events_array/ ),则无法访问开始日期和结束日期。 您需要使用上述两种方法之一。

您可以使用以下方式获取开始日期:

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

然后,只需将一周中的日期相加即可获得结束日期