比较时间的js

<script language="JavaScript">

 function check_confirm(form){
  var cks = queryForm1.elements;
  if (datecompare(cks[3].value,cks[5].value)==false) {
   alert("结束时间 应该在 开始时间 之后");
   return;
  }
  check(form);
 }

 //功能介绍:检查第一个日期是否小于第二个日期
 //参数说明:要检查的字符串(YYYY-MM-DD)
 //返回值:false:不是 true:是

 function datecompare(strDate1, strDate2){
  var  nYear2,   nMonth2,   nDay2;
  nYear1  = strDate1.substr(0,4);
  nMonth1 = strDate1.substr(5,2);
  nDay1   = strDate1.substr(8,2);
  nYear2  = strDate2.substr(0,4);
  nMonth2 = strDate2.substr(5,2);
  nDay2   = strDate2.substr(8,2);
  if ( nYear1 > nYear2 ) {
   return false;
  }
  if ( nYear1 == nYear2 ) {
   if (nMonth1 == nMonth2) {
    if ( nDay1 > nDay2 )
     return false;
   }
   if (nMonth1>nMonth2) {
    return false;
   }
  }
  return true;
 }
</script> 

----------------------------------调用方法------------------------------------------------

<input type="button"
      value="查询" οnclick="javascript:check_confirm(document.queryForm1);" class="button_w">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值