I'm looking to change the format of my date and time stamps on a scroll plugin.
The code is currently;
which showsCode:{ return ("Date: " + d.getDate() + "/" + d.getMonth()+1) + "/" + d.getYear().toString().substr(-2) + " - Time " + d.getHours() + ":" + d.getMinutes() }I want it to show:[Date: 11/11/12 - Time: 10:0 - 12:00]Why is the second zero missing???[Date: 11/11/12 - Time: 10:00 - 12:00]
Not sure what I'm doing wrong - the plugin script that deals with it is;
Code:date_formatter: function(d, allday_p) { if (allday_p) { return "" + (d.getFullYear()) + "-" + (pad_zero(d.getMonth() + 1)) + "-" + (pad_zero(d.getDate())); } else { return "" + (d.getFullYear()) + "-" + (pad_zero(d.getMonth() + 1)) + "-" + (pad_zero(d.getDate())) + " " + (pad_zero(d.getHours())) + ":" + (pad_zero(d.getMinutes())); } }, daterange_formatter: function(sd, ed, allday_p) { if (allday_p) { if (sd.getDate() !== ed.getDate() || sd.getMonth() !== ed.getMonth()) { return "" + (this.date_formatter(sd, allday_p)) + " - " + (pad_zero(ed.getMonth() + 1)) + "-" + (pad_zero(ed.getDate())); } else { return this.date_formatter(sd, allday_p); } } else { if (sd.getDate() !== ed.getDate() || sd.getMonth() !== ed.getMonth()) { return "" + (this.date_formatter(sd, allday_p)) + " - " + (pad_zero(ed.getMonth() + 1)) + "-" + (pad_zero(ed.getDate())) + " " + (pad_zero(ed.getHours())) + ":" + (pad_zero(ed.getMinutes())); } else if (sd.getHours() !== ed.getHours() || sd.getMinutes() !== ed.getMinutes()) { return "" + (this.date_formatter(sd, allday_p)) + " - " + (pad_zero(ed.getHours())) + ":" + (pad_zero(ed.getMinutes())); } else { return this.date_formatter(sd, allday_p); } } } };



Reply With Quote



Bookmarks