R Monkey
R Monkey

Reputation: 123

Cannot read properties of undefined (reading 'formatDate')

What's the problem in my code?

Cannot read properties of undefined (reading 'formatDate')

 editable:true,
    eventResize:function(event)
    {
    console.log(event.start);
    
     var start = $.fullCalendar.formatDate(event.start, "YYYY-MM-DD HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "YYYY-MM-DD HH:mm:ss");
     var title = event.title;
     var id = event.id;
     $.ajax({
      url:"../Components/calendar/update.php",
      type:"POST",
      data:{title:title, start:start, end:end, id:id},
      success:function(){
       calendar.fullCalendar('refetchEvents');
       alert('Event Update');
      }
     })
    }

Console.log of event.start

enter image description here

Upvotes: 2

Views: 6003

Answers (2)

Muhammad Azeem
Muhammad Azeem

Reputation: 79

When You select the start and end date on full calendar use following code as well:

select: function(start, end) {
                  
     var start_date = moment(start).format('YYYY-MM-DD HH:mm:ss'));
     var end_date = moment(end).format('YYYY-MM-DD HH:mm:ss'));

Upvotes: 0

R Monkey
R Monkey

Reputation: 123

this is old version

$.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");

Solution:

moment(event.start, 'DD.MM.YYYY').format('YYYY-MM-DD HH:mm:ss')

Upvotes: 2

Related Questions