Reputation: 4343
I have code like this:
dayClick: function(date, jsEvent, view) {
console.log(moment.utc(date).format());
$('#calendar').fullCalendar('renderEvent', {
title: 'sds',
start: moment.utc(date).format(),
allDay: false,
lazyFetching: false
}, true);
},
And new event never shows. I want to create event so I can manipulate it. I need it just for a representation of time in space - any ideas why it doesn't work?
Upvotes: 0
Views: 496
Reputation: 61794
Have a look at http://momentjs.com/docs/#/manipulating/utc/ - the "utc" function doesn't accept a parameter. I suspect your event is getting created, but on today's date instead of the date you clicked. I suspect you meant moment(date).utc()
, which would pass the date into moment's constructor and create a moment on that date.
However since date
is already a momentJS object (as per https://fullcalendar.io/docs/mouse/dayClick/), you can just call .utc()
on it directly anyway, without the constructor. You should do date.utc()
to set it, before you pass it to your event.
Overall:
dayClick: function(date, jsEvent, view) {
date.utc(); //set date to utc first
$('#calendar').fullCalendar('renderEvent', {
title: 'sds',
start: date.format(),
allDay: false,
lazyFetching: false
}, true);
},
Upvotes: 2