JS判断时间段的实现代码
网络 2017-06-22 1601
废话不多说了,直接给大家贴代码了,具体代码如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <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 = $('#bcconDateBeginDate').datetimebox('getValue'); 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('提示', '开始时间不能超过当前时间前7天!'); return; } } |
以上所述是小编给大家介绍的JS判断时间段的实现代码,希望对大家有所帮助