比较两个时间
时间格式是  2008-7-8 14:15:16

解决方案 »

  1.   

    直接比较就可以
    a="2008-7-8 14:15:16 ";
    b="2008-7-9 14:15:16 "
    if(a>b)
    {
       ......
    }
      

  2.   

    function ConvertToDateTime(str)
    {
    var a = str.match(/^(\d{0,4})-(\d{0,2})-(\d{0,2}) (\d{0,2}):(\d{0,2}):(\d{0,2})$/); 
    if (a == null) return null; 
    return new Date(a[1],a[2]-1,a[3],a[4],a[5],a[6]);
    }Date.parse(ConvertToDateTime(str1)) 比较符 Date.parse(ConvertToDateTime(str2))
      

  3.   

    time1='2008-01-13 08:08:08'
    time2='2008-01-12 08:08:08'
    t1=time1.replace(/-/g,"/");
    t2=time2.replace(/-/g,"/");
    alert((new Date(t1))>(new Date(t2)))