var validUntil = document.noticeInfoForm.elements["obj.validUntil"].value;
var str = validUntil.split("-");
alert(new Date() - new Date(str[0], str[1]-1, str[2])>0);
当我的validUntil=当前日期时,alert的结果还是TRUE。这个问题怎么解决啊!~
var str = validUntil.split("-");
alert(new Date() - new Date(str[0], str[1]-1, str[2])>0);
当我的validUntil=当前日期时,alert的结果还是TRUE。这个问题怎么解决啊!~
//给日期对象添加一个比较大小的函数,参数other是另外一个要比较的日期,当这个日期比另外一个日期大时返回1,比另外一个日期小时返回-1,两个日期相等时返回0
Date.prototype.CompareOther = function(other) {
return this.getYear() > other.getYear() ? 1 :
(this.getYear() < other.getYear() ? -1 :
(this.getMonth() > other.getMonth() ? 1 :
(this.getMonth() < other.getMonth() ? -1 :
(this.getDate() > other.getDate() ? 1 :
(this.getDate() < other.getDate() ? -1 : 0)))));
}
window.onload = function() {
var d = new Date(2011, 10, 10);
var i = "2010-11-10";
var str = i.split("-");
alert(new Date(str[0], str[1] - 1, str[2]).CompareOther(d));
}