简体   繁体   English

FullCalendar - eventDrop UTC日期

[英]FullCalendar - eventDrop UTC Date

I've set up this demo of FullCalendar: 我已经设置了FullCalendar的这个演示:

http://jsfiddle.net/k5de79b3/ http://jsfiddle.net/k5de79b3/

           eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {
                var eventData = {};
                eventData.event_id = event.id;
                eventData.start = event.start.toDate();

                var year = eventData.start.getUTCFullYear();
                var month = eventData.start.getUTCMonth() + 1;
                var day = eventData.start.getUTCDate();
                var hours = eventData.start.getUTCHours();
                var minutes = eventData.start.getUTCMinutes();
                var seconds = eventData.start.getUTCSeconds();
                if(month < 10){ month = '0' + month; }
                if(day < 10){ day = '0' + day; }
                if(hours < 10){ hours = '0' + hours; }
                if(minutes < 10){ minutes = '0' + minutes; }
                if(seconds < 10){ seconds = '0' + seconds; }

                eventData.start = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
                alert(eventData.start);
            }

to show how the date/time being returned for the dropped event is misleading. 显示如何为丢弃的事件返回的日期/时间具有误导性。

The drop handler is setup to return the UTC datetime of the dropped event. drop handler设置为返回已删除事件的UTC日期时间。 Yet you'll notice that if you drop an event on 11/10/2014 08:00:00 , that is the time that is returned. 但是你会注意到,如果你在11/10/2014 08:00:00放弃一个事件,那就是返回的时间。

I am in Pacific time zone ( -8 ) so if I'm using the calendar and drop an event on 2pm (my local time) shouldn't the UTC time returned be 10pm ? 我在太平洋时区( -8 ),所以如果我使用日历并在下午2点 (当地时间)放弃一个活动,那么UTC时间不应该是晚上10点

Has anyone else noticed this behavior? 有没有人注意到这种行为?

To get the results you want, you need to add timezone:'local' when you initialize the calendar. 要获得所需的结果,您需要在初始化日历时添加timezone:'local'

The default for timezone in FullCalendar is "no timezone", as specified in the docs . FullCalendar中timezone的默认值是“no timezone”, 如文档中所指定 So no, it isn't accounting for your local time. 所以不,这不符合您当地的时间。

View the differences using this more-readable version of your code as you posted (no timezone) against a version where it will use your local timezone . 使用这个更易阅读的代码版本查看差异因为您发布了(没有时区)与使用本地时区的版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM