Home > Web Front-end > JS Tutorial > Implementation code for javascript to determine time period

Implementation code for javascript to determine time period

陈政宽~
Release: 2017-06-28 12:41:30
Original
1822 people have browsed it

This article will share with you a piece of example code to introduce the method of JS judging the time period. Friends who need it can refer to it

No more nonsense, I will post the code directly for you. The specific code is as follows:

<th>交易时间开始:</th>             

<td><input id="bcconDateBeginDate" name="bcconDateBeginDate" value="2016/06/12 00:00:00" class="easyui-datetimebox" editable="false" style="width: 150px;" /></td> 
            <th>交易时间结束:</th> 
            <td><input id="bcconDateEndDate" name="bcconDateEndDate" value="2016/06/12 23:59:59" class="easyui-datetimebox" editable="false" style="width: 150px;" /></td> 
var v = $(&#39;#bcconDateBeginDate&#39;).datetimebox(&#39;getValue&#39;); 
  if(v.length>0){ 
    var date = new Date(); 
    var year = date.getFullYear(); 
    var month = date.getMonth() + 1; 
    var strDate = date.getDate(); 
    if (month >= 1 && month <= 9) { 
      month = "0" + month; 
    } 
    if (strDate >= 0 && strDate <= 9) { 
      strDate = "0" + strDate; 
    } 
    var nowdate = year+"/"+month+"/"+strDate; 
    var data1 = Date.parse(v.substring(0,10).replace(/-/g,"/"));  
    var data2 = Date.parse(nowdate); 
    var datadiff = data2-data1;  
    var time = 6*24*60*60*1000;  
    if(datadiff>time){ 
      $.messager.alert(&#39;提示&#39;, &#39;开始时间不能超过当前时间前7天!&#39;); 
      return; 
    } 
  }
Copy after login

The above is the JS implementation code for judging the time period introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for your support of the Script House website!

The above is the detailed content of Implementation code for javascript to determine time period. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template