Moment (). format () and fullcalendar: undefined is not a function

I am 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 and drop an item from the calendar an error like this occurs: Uncaught TypeError: undefined is not a function

I did some debugging and the error was caused by moment (). format () Can anyone help me?

+3


source to share


1 answer


If you get this error on this 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 is a timedate

you should do this:

ev_start = moment(event.start).format("dddd (d) DDD - D/MM/YY");

      

+6


source







All Articles