本地和发布

时间:2018-05-16 06:31:12

标签: c# jquery timezone fullcalendar momentjs

当fullcalendar在本地机器上实现时,它可以正常工作。但是当我在位于英国的服务器中进行托管时,时间事件未正确分配。时区问题是原因.NB:将时区选项更改为本地到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”));                 // DateTime monday = Date.start.Date;                 Log activeDates = new Log();                 activeDates.Date = start.Date;                 activeLogs = await GDiaryBLL.GetUserLogsByUserID(activeDates);

this how same event in local displayed in when i published in uk server date difference check the dates as well as event

same event in local machine

1 个答案:

答案 0 :(得分:0)

通过更改时区修复的问题:" UTC" 更改数据格式