开发者

jQuery FullCalendar Date Storage Problem (RFC-822)

开发者 https://www.devze.com 2023-03-13 03:28 出处:网络
Is there a way to have the date that FullCalendar stores into the DB in a date or datetime format, or some other time forma开发者_运维百科t instead of varchar, so I can do a sort by date SQL call?

Is there a way to have the date that FullCalendar stores into the DB in a date or datetime format, or some other time forma开发者_运维百科t instead of varchar, so I can do a sort by date SQL call?

Right now it's being stored as Mon Jun 13 2011 12:30:00 GMT-0400 (EDT) which is impossible to sort.


You can format the date as you wish and send it to DB. For example if you have only whole-day-events you can add a date prototype:

    Date.prototype.toYMD = function() {
       var year, month, day;
       year = String(this.getFullYear());
       month = String(this.getMonth() + 1);
       if (month.length == 1) {
           month = "0" + month;
       }
       day = String(this.getDate());
       if (day.length == 1) {
           day = "0" + day;
       }
       return year + "-" + month + "-" + day;
    };

you can convert your date to MySQL-formatted one using:

    var strID = j.toYMD();
    alert("strID: "+strID);

If you need hour, minutes and secs you can extend the above example. cheers Kris

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号