Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eventDrop callback date seems off by 1 day for the all-day use case

Tags:

fullcalendar

I am printing event.start to the console upon eventDrop. When I drag an event to an all-day slot, the dates are off by a day, when I drag a normal agenda hour the date seems fine.

Example: http://jsfiddle.net/FxFba/361/

Drag event one to an allDay (6/2) positions and note the console log - Sun Jun 01 2014 17:00:00 GMT-0700 (PDT)

Now drag to a time agenda slot (6/2 7am) and notice the console log - Mon Jun 02 2014 07:00:00 GMT-0700 (PDT)

Are all days rolling back to the previous day for its start? Or am I missing something obvious?

fullCalendar({
header: {
    left: 'prev,next today',
    center: 'title',
    right: 'month,agendaWeek,agendaDay'
},
timezone: 'local',
editable: true,
defaultView: 'agendaWeek',
eventDrop : function(event,jsEvent,ui,view){
     console.log(event.start.toDate());  
},
events: [
    {
        title  : 'event1',
        start  : '2014-06-01'
    },
    {
        title  : 'event2',
        start  : '2014-06-06',
        end    : '2010-06-07'
    }
]
}

Thanks, Jeff

like image 503
Jeff I Avatar asked Jan 21 '26 07:01

Jeff I


1 Answers

FullCalendar has Moment.js as a dependency, and Moment, in turn, has a method .utc(), which when used to format your date, can counteract the adding and subtracting of hours due to your timezone difference.

Something like

var configuredTime = moment(date._d).utc().format("MM-DD-YYYY");

may work for you, if you are using the drop callback:

drop: function(date, jsEvent, ui, resourceId) {}

Check out

http://momentjs.com/docs/#/parsing/utc/

like image 65
GuillermoK Avatar answered Jan 23 '26 19:01

GuillermoK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!