当在本地机器中实现完整日历时,它可以正常工作。但是当我尝试在位于英国的服务器中托管时,时间事件未正确分配。时区问题是原因。注意:将时区选项更改为本地 UTC 或反之亦然无济于事。
后端:c# MVC
插件使用版本:
FullCalendar v3.6.1
Moment.js :version : 2.19.2
要求:
事件应正确显示给印度用户和时区不同的用户
var calendar = $('#calendarForGDiary');
calendar.fullCalendar(fullCalendarOptions());
function fullCalendarOptions() {
var options = {
lazyFetching: false,
editable: true, // Don't allow editing of events
handleWindowResize: true,
weekends: true, // Hide weekends
defaultView: 'agendaWeek', // Only show week view
header: true, // Hide buttons/titles
minTime: '00:00:00', // Start time for the calendar
maxTime: '24:00:00', // End time for the calendar
overlap: false,
timezone: 'local',
eventConstraint: {
start: '0:00',
end: '24:00'
},
droppable: true,
drop: function (date) {
},
timeFormat: 'HH:mm',
defaultTimedEventDuration: '01:00',
axisFormat: 'HH:mm',
slotLabelFormat: "HH:mm",
eventOverlap: false,
allDaySlot: false,
slotDuration: '00:05',
slotLabelInterval: '01:00',
header: {
left: 'title',
center: '',
right: 'today prev,next, Date'
},
firstDay: 1,
businessHours: {
// days of week. an array of zero-based day of week integers (0=Sunday)
dow: [1, 2, 3, 4, 5],
start: '00:00', // a start time
end: '7:30', // an end time
},
displayEventTime: true,
views: {
agenda: {
timeFormat: 'HH:mm', // uppercase H for 24-hour clock
columnFormat: 'ddd DD/MM/YY',
}
},
dragRevertDuration: 0,
events:{
url: '@Url.Action("GetIssueLogsByDate")',
type: 'POST',
success: function ()
{
$.fullCalendar.moment().stripZone()
},
error: function () { ShowErrorModal("Unable To Load Log Details") }
},
scrollTime: "00:00:00",
eventDrop: function (event, delta, revertFunc) {
ChangeIssueLogDate(event);
},
eventReceive: function (event) {
addNewEvent(event);
},
loading: function (bool) {
$('#imgLoadingForGemini').modal('show');
},
eventAfterAllRender: function (view)
{
modifyCalendarForTimeOverflow();
$('.eventButtons').attr('disabled', 'disabled');
$('#imgLoadingForGemini').modal('hide');
},
eventClick: function (event, jsEvent) {
ShowEventDetailsModal(event, jsEvent);
},
eventResize: function (event, delta, revertFunc) {
UpdateLogTimeByLogID(delta._data, event.id);
},
eventRender: function (event, element, view)
{
// moment(event._d.start, 'DD.MM.YYYY').format('YYYY-MM-DD')
//$.fullCalendar.moment(event.d).stripZone()
console.log(event)
},
moment: { stripZone:true },
}
return options
}
控制器代码 public async Task GetIssueLogsByDate(DateTime start) { 尝试 { start = DateTime.Parse(start.ToString("MM-dd-yyyy")); 日期时间星期一 = 日期.开始.日期; 日志活动日期 = 新日志(); activeDates.Date = start。日期; activeLogs = await GDiaryBLL.GetUserLogsByUserID(activeDates);
当我在英国发布时,本地显示的相同事件如何 服务器日期差异 检查日期和事件
本地计算机中的相同事件
通过更改时区修复的问题:"UTC" 更改数据的格式