Home  >  Article  >  Web Front-end  >  JS 日期比较大小的简单实例_javascript技巧

JS 日期比较大小的简单实例_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:04:131206browse
1,比较日期大小的js代码
复制代码 代码如下:

<script><BR>var beginDate=$("#beginDate").val(); <BR> var endDate=$("#endDate").val(); <BR> var d1 = new Date(beginDate.replace(/\-/g, "\/")); <BR> var d2 = new Date(endDate.replace(/\-/g, "\/")); <br><br> if(beginDate!=""&&endDate!=""&&d1 >=d2) <BR> { <BR> alert("开始时间不能大于结束时间!"); <BR> return false; <BR> }<BR> </script>

2,Js比较时间和日期大小
复制代码 代码如下:

  
  
calendar-比较时间和日期大小-www.jb51.net  
  
  
  
开始时间:到    
结束时间:  
            
            
  

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn