我从From表单中回去一个yyyy-MM-dd格式的日期,要与在JS中用NEW DATE()方法获得的日期比较!~~在网上找了些方法,感觉都不太好!~~~所以来请教了哈!~~·

解决方案 »

  1.   

    var i = "1999-10-10";
    alert((new Date() - new Date(i))>0);
      

  2.   

     var validUntil = document.noticeInfoForm.elements["obj.validUntil"].value;
     alert(new Date(validUntil));
    提示NAN,我直接alert(validUntil)是有日期的!~~~
      

  3.   

    var i = "2010-11-10";
    var str = i.split("-");
    alert(new Date() - new Date(str[0], str[1]-1, str[2]));
      

  4.   

    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();
    var i = "2010-11-10";
    var str = i.split("-");
    alert(d.CompareOther(new Date(str[0], str[1] - 1, str[2])));
    }
      

  5.   

    可以稍微解释下吗,兄台!~~
    CompareOther()收尾的}有警告是为什么呢0 0!~~~