最好是不管时间格式是什么样的,只要两个时间格式正确,就能判断他们大小的方法????

解决方案 »

  1.   

    Date.parse(new Date(时间1))>Date.parse(new Date(时间1))
      

  2.   

    var t1="2009/10/10";
    var t2="2009/10/9";
    if(Date.parse(new Date(时间1))>Date.parse(new Date(时间1)) )
    alert();
    else
    alert();
      

  3.   

           //Time对象   
            function TimeCom(Value)   
            {   
                var newCom = new Date(value);   
                this.year = newCom.getYear();   
                this.month = newCom.getMonth()+1;   
                this.day = newCom.getDate();   
                this.hour = newCom.getHours();   
                this.minute = newCom.getMinutes();   
                this.second = newCom.getSeconds();   
                this.msecond = newCom.getMilliseconds();   
                this.week = newCom.getDay();   
            }   
            //对日期相减,并计算得出结果,返回两个时间的相差秒数   
            function DateDiff(begindate,enddate)   
            {   
                var TimeCom1 = new TimeCom(begindate);   
                var TimeCom2 = new TimeCom(enddate);   
                var result;   
                            //转换为标准的格林尼治时间进行计算   
                return Math.round((Date.UTC(TimeCom1.year,TimeCom1.month-   
      
    1,TimeCom1.day,TimeCom1.hour,TimeCom1.minute,TimeCom1.second)-Date.UTC(TimeCom2.year,TimeCom2.month-   
      
    1,TimeCom2.day,TimeCom2.hour,TimeCom2.minute,TimeCom2.second))/1000);   
                   
            }   
            //通过DateDiff返回的结果计算显示需要的数据   
            function TimeGet(Value)   
            {   
                var secondTotal=parseInt(Value)   
                this.day=Math.round(secondTotal/(60*60*24));   
                secondTotal=secondTotal%(60*60*24);   
                this.hour=Math.round(secondTotal/(60*60));   
                secondTotal=secondTotal%(60*60);   
                this.minute=Math.round(secondTotal/(60));   
                secondTotal=secondTotal%(60);   
                this.second=secondTotal;   
                   
                   
            }  本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/tkascor/archive/2009/09/10/4538556.aspx
      

  4.   

    我是这么写的,但是一点效果也没哟!!
        function tijiao()
        {
            var t=document.getElementById("TextBox1").value;
            var t2=document.getElementById("TextBox2").value;        if(Date.parse(new Date(t))>Date.parse(new Date(t2))) 
            {
                alert("停牌时间必须在比赛时间之前!");
                return false;
            }
            return true;
        }
      

  5.   

    我是这样写的,但是,不管 t 和 t2 的值是什么,弹出的都是 alert("aa")
            var t=document.getElementById("TextBox1").value;
            var t2=document.getElementById("TextBox2").value;        if(Date.parse(new Date(t))>Date.parse(new Date(t2))) 
            {
                alert("a");
                return false;
            }else
            {
                alert("aa");
            }