如何确定FullCalendar的日程视图中的开始日期和结束日期? [英] How do I determine the start and end date on the agendaWeek view in FullCalendar?

查看:4136
本文介绍了如何确定FullCalendar的日程视图中的开始日期和结束日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定制了以CalendarWeek作为视图的FullCalendar事件的宽度和位置。我需要知道本周的开始和结束日期。



我知道我可以使用$('#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 
_ 参数会自动插入,以防止浏览器缓存结果。


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

  $('#calendar')。fullCalendar({
events:function(start ,end,callback){
//操作开始和结束对象
}
});

如果您只是提供一组事件日期(按照 http://arshaw.com/fullcalendar/docs/event_data/events_array/ ),开始和结束日期不是无障碍。您需要使用上述两种方法中的一种。


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 current 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.

这篇关于如何确定FullCalendar的日程视图中的开始日期和结束日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆