fullcalender.formatdate not working

后端 未结 4 1717
长情又很酷
长情又很酷 2020-12-19 21:18

I am trying to integrate fullcalender to php mysql.I have used the following code.I want to format the date such it will come in format yyyy/mm/dd but when i use format stat

4条回答
  •  情深已故
    2020-12-19 22:09

    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.

提交回复
热议问题