javascript - FullCalendar - eventDrop UTC Date - Stack Overflow

I've set up this demo of FullCalendar:eventDrop: function(event,dayDelta,minuteDelta,allDay,rever

I've set up this demo of FullCalendar:

/

           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. Yet you'll notice that if you drop an event on 11/10/2014 08:00:00, that is the time that is returned.

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?

Has anyone else noticed this behavior?

I've set up this demo of FullCalendar:

http://jsfiddle/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. Yet you'll notice that if you drop an event on 11/10/2014 08:00:00, that is the time that is returned.

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?

Has anyone else noticed this behavior?

Share Improve this question asked Nov 12, 2014 at 1:34 A.O.A.O. 3,7636 gold badges32 silver badges49 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

To get the results you want, you need to add timezone:'local' when you initialize the calendar.

The default for timezone in FullCalendar is "no timezone", as specified in the docs. 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744690002a4588153.html

相关推荐

  • javascript - FullCalendar - eventDrop UTC Date - Stack Overflow

    I've set up this demo of FullCalendar:eventDrop: function(event,dayDelta,minuteDelta,allDay,rever

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信