如何在fullcalendar上获得开始和结束时间?

时间:2022-09-26 11:48:42

how can i get start and end time of visible days in fullcalendar?

如何在fullcalendar中获得可见日的开始和结束时间?

I need it for use in another javascript instace. Is there some function like -

我需要它在另一个javascript instace中使用。是否有一些功能 - 如

$('calender').getStartTime();

?

4 个解决方案

#1


43  

If you're looking for the visible start and end date, that would be the visStart and visEnd property of the view object in version 1:

如果您正在查找可见的开始和结束日期,那么将是版本1中视图对象的visStart和visEnd属性:

$('calender').fullCalendar('getView').visStart

$('calender').fullCalendar('getView').visEnd

and that would be intervalStart and intervalEnd in version 2:

那将是版本2中的intervalStart和intervalEnd:

$('calender').fullCalendar('getView').intervalStart

$('calender').fullCalendar('getView').intervalEnd

If you're looking for the start and end date of the current week / month, that would be the start and end property of the current view object:

如果您正在查找当前周/月的开始和结束日期,那么这将是当前视图对象的开始和结束属性:

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

$('calendar').fullCalendar('getView').end

Reference : Full Calendar documentation.

参考:完整日历文档。

#2


3  

$('calendar').fullCalendar('getView').start
$('calendar').fullCalendar('getView').end

#3


2  

I don't know why I'm seeing such different behavior but thanks to the others, I got in the right direction but the "start" and "end" are moment() objects. Thus to get the actual date, you need to use:

我不知道为什么我看到这种不同的行为,但多亏其他人,我得到了正确的方向,但“开始”和“结束”是moment()对象。因此,要获得实际日期,您需要使用:

$('calendar').fullCalendar("getView").start.format()
$('calendar').fullCalendar("getView").end.format()

Works exactly like I need and what the OP asked. NOTE: The end date is one day after the calendar. That is, the calendar I'm looking at starts on Sunday 7/31/16 ends on Saturday 9/10/16 - and the date given me are 2016-07-31 and 2016-09-11 (one day after the date shown technically - of course if you say "00:00:00" of those days you'll be accurate).

完全像我需要的工作和OP提出的要求。注意:结束日期是日历之后的一天。也就是说,我正在观看的日历将于2016年7月31日星期日开始于2016年10月9日星期六结束 - 而且给出的日期是2016-07-31和2016-09-11(日期后一天)技术上显示 - 当然,如果你说那些日子的“00:00:00”你会准确的)。

#4


1  

You need to give id/class what you specified jquery full calendar

你需要给id / class你指定的jquery完整日历

    var start_date =  $('#schedule-events').fullCalendar('getView').start
    var end_date  =   $('#schedule-events').fullCalendar('getView').end

Above #schedule-events of the full calendar .. you should give the id of the full calendar

在完整日历的#schedule-events之上..你应该给出完整日历的id

Example :

示例:

   $('#schedule-events').fullCalendar({

            eventRender: function(event, element) {

          var start_date =  $('#schedule-events').fullCalendar('getView').start
          var end_date  =   $('#schedule-events').fullCalendar('getView').end
          console.log(start_date +'sart----------end date'+end_date)

                  }

......................etc..........

......................等等..........

#1


43  

If you're looking for the visible start and end date, that would be the visStart and visEnd property of the view object in version 1:

如果您正在查找可见的开始和结束日期,那么将是版本1中视图对象的visStart和visEnd属性:

$('calender').fullCalendar('getView').visStart

$('calender').fullCalendar('getView').visEnd

and that would be intervalStart and intervalEnd in version 2:

那将是版本2中的intervalStart和intervalEnd:

$('calender').fullCalendar('getView').intervalStart

$('calender').fullCalendar('getView').intervalEnd

If you're looking for the start and end date of the current week / month, that would be the start and end property of the current view object:

如果您正在查找当前周/月的开始和结束日期,那么这将是当前视图对象的开始和结束属性:

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

$('calendar').fullCalendar('getView').end

Reference : Full Calendar documentation.

参考:完整日历文档。

#2


3  

$('calendar').fullCalendar('getView').start
$('calendar').fullCalendar('getView').end

#3


2  

I don't know why I'm seeing such different behavior but thanks to the others, I got in the right direction but the "start" and "end" are moment() objects. Thus to get the actual date, you need to use:

我不知道为什么我看到这种不同的行为,但多亏其他人,我得到了正确的方向,但“开始”和“结束”是moment()对象。因此,要获得实际日期,您需要使用:

$('calendar').fullCalendar("getView").start.format()
$('calendar').fullCalendar("getView").end.format()

Works exactly like I need and what the OP asked. NOTE: The end date is one day after the calendar. That is, the calendar I'm looking at starts on Sunday 7/31/16 ends on Saturday 9/10/16 - and the date given me are 2016-07-31 and 2016-09-11 (one day after the date shown technically - of course if you say "00:00:00" of those days you'll be accurate).

完全像我需要的工作和OP提出的要求。注意:结束日期是日历之后的一天。也就是说,我正在观看的日历将于2016年7月31日星期日开始于2016年10月9日星期六结束 - 而且给出的日期是2016-07-31和2016-09-11(日期后一天)技术上显示 - 当然,如果你说那些日子的“00:00:00”你会准确的)。

#4


1  

You need to give id/class what you specified jquery full calendar

你需要给id / class你指定的jquery完整日历

    var start_date =  $('#schedule-events').fullCalendar('getView').start
    var end_date  =   $('#schedule-events').fullCalendar('getView').end

Above #schedule-events of the full calendar .. you should give the id of the full calendar

在完整日历的#schedule-events之上..你应该给出完整日历的id

Example :

示例:

   $('#schedule-events').fullCalendar({

            eventRender: function(event, element) {

          var start_date =  $('#schedule-events').fullCalendar('getView').start
          var end_date  =   $('#schedule-events').fullCalendar('getView').end
          console.log(start_date +'sart----------end date'+end_date)

                  }

......................etc..........

......................等等..........