I am using selectable function where when user select a date, it will shows the start and end date in a modal. but the the end date showed is extra one day from the actual selected date. for example, of i click on 1st march, the end date will showed 2nd march. here is my code:
select: function (start, end, allDay, jsEvent, view) {
var view = $('#calendar').fullCalendar('getView');
$("#EndDate").val('');
alert(end);
if (view.name === "month") {
$('#DateForm').modal('show');
$("#EndDate").val(start.format('ddd, DD-MMM-YYYY, hh:mm a'));
} else {
}
}
The calendar's dates can change any time the user does the following: click the prev/next buttons, change the view, click a navlink. The dates can also change when the current-date is manipulated via the API, such as when gotoDate is called. datesSet is called after the new date range has been rendered.
We can get start date by getView event with intervalStart. We can get end date by getView event with intervalEnd. var month = $('#calendar'). fullCalendar('getView').
Detect when the user clicks on dates or times. Give the user the ability to select multiple dates or time slots with their mouse or touch device. Allows a user to highlight multiple days or timeslots by clicking and dragging.
for disable cell on click (version 2.0) : dayRender: function( date, cell ) { // It's an example, do your own test here if(cell. hasClass("fc-other-month")) { cell. addClass('disabled'); } }, dayClick: function(date, jsEvent, view) { if($(jsEvent.
What you're seeing is the correct, documented behaviour. The documentation of the "end" property of an event states:
The exclusive date/time an event ends. [...] It is the moment immediately after the event has ended. For example, if the last full day of an event is Thursday, the exclusive end of the event will be 00:00:00 on Friday!
See https://fullcalendar.io/docs/event-object for more.
P.S. the line var view = $('#calendar').fullCalendar('getView');
in your code above is redundant - you already have access to the view via the parameter of the same name in your callback. You can remove this line and the code will continue to work.
You can do this in this way
select: function (start, end, allDay, jsEvent, view) {
var endDate = new Date(end);
beforeDay = new Date(endDate.getFullYear(),endDate.getMonth(),endDate.getDate() - 1);
$("#EndDate").val(beforeDay.format('ddd, DD-MMM-YYYY, hh:mm a'));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With