24

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

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

$('calender').getStartTime();

?

7 Answers 7

50

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:

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

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

and that would be intervalStart and intervalEnd in version 2:

$('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
  • 1
    In the latest version (V2), the properties are intervalStart and intervalEnd instead of visStart and visEnd (docs: arshaw.com/fullcalendar/docs/views/View_Object) :-) Jul 16, 2014 at 3:50
  • 2
    This answer is great, however the wording confused me slightly. intervalStart and intervalEnd are the beginning and end of the time interval the calendar wants to represent, so for example they will be first and last day of current month, even if days from previous/next month are shown. start and end give the beginning and end of the actual time that is shown, including days outside of month. Jul 2, 2015 at 7:33
7

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:

$('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).

6

version 5

var start = calendar.view.activeStart;
var end = calendar.view.activeEnd;

Docs: https://fullcalendar.io/docs/view-object

4

version 4

You can just use calendar object and get satrt/end dates

 var start = calendar.view.view.activeStart;
 var end = calendar.view.view.activeEnd;
3
$('calendar').fullCalendar('getView').start
$('calendar').fullCalendar('getView').end
2

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

    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

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

2

Just posting it for others who might be looking for angular solution.

For start date this.calendar.getApi().view.activeStart and for end date this.calendar.getApi().view.activeEnd

You can follow https://fullcalendar.io/docs/angular to get fullcalendar api - getApi() to use above methods.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.