1
函數接收兩個日期的格式之間是: YYYY/MM/DDTHH:MMjavascript日期發行瀏覽器
年/月/ dayThour:分
包住不明確的
function compareDates(start, end) {
console.log("Start: " + start);
console.log("END : " + end);
var start1 = start.replace(/\T/g,' ')
var start2 = new Date(start1);
var end1 = end.replace(/\T/g,' ')
var end2 = new Date(end1);
console.log("Str 1: " + start1);
console.log("Str 2: " + start2);
console.log("END 1: " + end1);
console.log("END 2: " + end2);
console.log((end - start));
console.log((end - start) < 0);
if ((end - start) < 0 || (end - start) == 0) {return false;}else{return true}
}
調試前的原始碼
function compareDates(start, end) {
start = new Date(start.replace(/\T/g,' '));
end = new Date(end.replace(/\T/g,' '));
if ((end - start) < 0 || (end - start) == 0) {return false;}else{return true}
}
調音臺有m y錯誤日誌記錄,在鉻這工作正常,沒有錯誤,如果結束日期等於或在我的開始日期之前返回false。
如果我在網上運行工作,我得到下面的輸出問題 海峽2:無效的日期 END 2:無效的日期
我不明白的是爲什麼這不會在黑莓網絡工作 - 工作,但在鉻中,我該如何解決這個問題?
謝謝
將嘗試它添加更多的代碼,如果有幫助 – LmC 2012-07-24 14:59:40
我如何比較2010/10/10 10:10至2010/10/10 10:09? – LmC 2012-07-24 15:15:24
當你嘗試時會發生什麼? – codebox 2012-07-24 16:10:42