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 badges1 Answer
Reset to default 9To 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
评论列表(0条)