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
精彩评论