I'm trying to use moment().format() with fullcalendar; I have this code:
<script src="<?php echo ASSETS_URL; ?>/js/plugin/fullcalendar/lib/moment.js"></script>
<script> moment().format() </script>
<script type="text/javascript">
$('#calendar').fullCalendar({
header: hdr,
buttonText: {
prev: '<i class="fa fa-chevron-left"></i>',
next: '<i class="fa fa-chevron-right"></i>'
},
defaultView: "agendaWeek",
editable: true,
droppable: false, // this allows things to be dropped onto the calendar !!!
lang: 'it',
timeFormat: 'H(:mm)',
firstDay: 1,
drop: function (date, allDay) { // this function is called when something is dropped
events: [{
}],
eventDragStart: function( event, jsEvent, ui, view ) {
ev_start=event.start.moment().format("dddd (d) DDD - D/MM/YY");
console.log(ev_start);
},
},
When I drag an element from calendar there is this error: Uncaught TypeError: undefined is not a function
I done some debug and the error is caused by moment().format() Anyone could help me?
If you receive that error on that line, check your moment.js file is good.
Then, this line is wrong:
ev_start=event.start.moment().format("dddd (d) DDD - D/MM/YY");
If event.start
it's a timedate
you should do this:
ev_start = moment(event.start).format("dddd (d) DDD - D/MM/YY");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With