`

js获取时间,比较时间

    博客分类:
  • js
 
阅读更多
//委托日期
        function onClientenddateValidation(e) {
         	var currentDate = CurentTime();
            if (e.isValid) {
           		var d1 = new Date(currentDate.replace(/\-/g, "\/"));  
 				var d2 = new Date(e.value.replace(/\-/g, "\/"));  
                if (d1<d2) {
                   e.isValid = true;
                }else{
                 	e.errorText = "委托有效截止日期必须大于当前日期";
                    e.isValid = false;
                }
            }
        }
        function CurentTime()
    	{ 
	        var now = new Date();
	       
	        var year = now.getFullYear();       //年
	        var month = now.getMonth() + 1;     //月
	        var day = now.getDate();            //日
	       
	//         var hh = now.getHours();            //时
	//         var mm = now.getMinutes();          //分
	//         var ss = now.getSeconds();          //秒
			var hh=0;
			var mm=0;
			var ss=0;
	       
	        var clock = year + "-";
	       
	        if(month < 10)
	            clock += "0";
	       
	        clock += month + "-";
	       
	        if(day < 10)
	            clock += "0";
	           
	        clock += day + " ";
	       
	        if(hh < 10)
	            clock += "0";
	           
	        clock += hh + ":";
	        if (mm < 10) clock += '0'; 
	        clock += mm; 
        
	        clock +=":";
	         if (ss < 10) clock += '0'; 
	        clock += ss; 
	        return(clock); 
    	} 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics