gpt4 book ai didi

javascript - 全日历选择错误的结束日期

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:10:37 26 4
gpt4 key购买 nike

我正在使用可选功能,当用户选择一个日期时,它将以模式显示开始和结束日期。但显示的结束日期比实际选择的日期多一天。例如,我点击 3 月 1 日,结束日期将显示 3 月 2 日。这是我的代码:

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

参见 https://fullcalendar.io/docs/event-object了解更多。


附言上面代码中的 var view = $('#calendar').fullCalendar('getView'); 行是多余的 - 您已经可以通过同名参数访问 View 打回来。您可以删除此行,代码将继续工作。

关于javascript - 全日历选择错误的结束日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49126166/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com