您的位置:首页 > Web前端 > JavaScript

js:判断当前时间和某个时间的比较

2012-12-14 15:09 267 查看
function checkAheadNowDate(){

    var now = new Date();

    var year = new Date().getFullYear();

     var month = new Date().getMonth()+1;

     var Minutes=now.getMinutes();

     var Seconds=now.getSeconds();

  var Hours = now.getHours();

     if (month<10){month="0"+month;}

     var today=new Date().getDate();

     if (today<10){ today="0"+today; }

     if(Minutes<10){Minutes="0"+Minutes;}

  if(Hours<10){Hours="0"+Hours;}

     if (Seconds<10){ Seconds="0"+Seconds; }

     var nowTime = year + "-" + month + "-" + today+' '+Hours + ":" + Minutes+":"+ Seconds;

 

    if (document.all('recordTask.beginTime').value < nowTime) {

         alert("开始时间必须晚于当前时间");

         return false;

     }

     return true;

 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: