fullcalender.formatdate not working

五迷三道 提交于 2019-11-29 12:40:16

First if you are looking for date only not hours, you should probably use:

start = $.fullCalendar.formatDate(start, "yyyy/MM/dd");
end = $.fullCalendar.formatDate(end, "yyyy/MM/dd");

Instead of this:

start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");

If you remove date format it seems working because it's inserting dates like a timestamp (it looks like timestamp). Try changing your database structure type to VARCHAR and you will see something like this:

1405468800000

When you are using dateFormat function, you should look in your web browser console logs. You'll probably see:

Uncaught TypeError: undefined is not a function

It's because $.fullCalendar.formatDate method no more exist on fullCalendar V2 (changeLog). You may use Moment.js with .format() method (doc).

Don't forget to import moment.js and edit your start and end variables to:

start=moment(start).format('YYYY/MM/DD');
end=moment(end).format('YYYY/MM/DD');

It should fix your issues.

this code below should do the trick. (assuming you have the moment.min.js lib)

        start=moment(start).format('YYYY-MM-DDTHH:mm:ssZ'); 
        end=moment(end).format('YYYY-MM-DDTHH:mm:ssZ'); 
LeGEC

As Tifa's answer suggests : if you don't need the time part, don't encode it :

start = $.fullCalendar.formatDate(start, "yyyy-MM-dd");

Another problem lies in the parameter string you pass to your ajax request :

data: 'title='+ title+'&start='+ start +'&end='+ end  ,

This string is not url encoded.

The easiest way to correct this is to pass an object, and let jQuery handle the encoding :

data: {'title': title, 'start': start, 'end': end } ,
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!