Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将字符串转换为日期对象并在js中进行比较_Javascript_Asp.net - Fatal编程技术网

Javascript 将字符串转换为日期对象并在js中进行比较

Javascript 将字符串转换为日期对象并在js中进行比较,javascript,asp.net,Javascript,Asp.net,如何比较两个类似这种格式的日期 var CurrDate = new Date().format("MM/dd/yyyy"); if (Date.parse("05-Jun-2012")>Date.parse(CurrDate)) { alert("Please enter future date!"); return false; } 请帮助验证日期。重复的问题。在这里找到你的答案。谢谢Neha。工

如何比较两个类似这种格式的日期

     var CurrDate = new Date().format("MM/dd/yyyy");
     if (Date.parse("05-Jun-2012")>Date.parse(CurrDate))
        {
         alert("Please enter future date!");
         return false;
        }

请帮助验证日期。

重复的问题。在这里找到你的答案。谢谢Neha。工作正常。我也想和当前日期进行比较。可能吗?
function customParse(str) {
  var months = ['Jan','Feb','Mar','Apr','May','Jun',
                'Jul','Aug','Sep','Oct','Nov','Dec'],
      n = months.length, re = /(\d{2})-([a-z]{3})-(\d{4})/i, matches;

  while(n--) { months[months[n]]=n; } // map month names to their index :)

  matches = str.match(re); // extract date parts from string

  return new Date(matches[3], months[matches[2]], matches[1]);
}

customParse("18-Aug-2010");
// "Wed Aug 18 2010 00:00:00"

customParse("19-Aug-2010") > customParse("18-Aug-2010");