比较javascript:IE 8异常中的日期



我尝试了以下代码来比较两个日期

    //the following check validates that the date is entered in the right format and it works
    if(s_period=="" || !date_format.exec(s_period))
    {
            alert("Please enter start date as YYYY-MM-DD");
            return false;
    }
    //next, i want to check if s_period is greater than '2013-06-30'
     if((new Date(s_period).getTime()) < (new Date("2013-07-01").getTime()))
     {
            alert("Stat available from 2013-07-01");
            return false;
      }

上面关于选择2013-06-30之后的日期的警告在Firefox中被调用,但在IE8上没有。有人能建议我添加额外的代码,使其在所有浏览器版本中都能工作吗?感谢

尝试Date.parsehttp://msdn.microsoft.com/en-us/library/ie/k4w173wk(v=vs.94).aspx

例如

if((Date.parse(s_period)) < (Date.parse("2013-07-01")))

最新更新