javascript 时间加减 分钟

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/educast/article/details/54667529
	 var mintime=new Date(); 
		  var minyear=mintime.getFullYear(); 
		  var mindate=mintime.getDate(); 
		  var minhour=mintime.getHours(); 
		  var minmonth=mintime.getMonth()+1;
		  var minmin=0;
		  var mintimstr=minyear+"-"+minmonth+"-"+mindate+" "+minhour+":00:00";
		   $("#minutetimeval").val(mintimstr);
		   $("#label7btnshour").click(function(){ 
		       var minutevaluetype=$('input[name="minutevaluetype"]:checked').val();
		       var minutetimeval=$("#minutetimeval").val();	
		       var date=new Date(minutetimeval);		       	       
				var t = date.getTime();
				t -= minutevaluetype*60*1000;//秒
				date.setTime(t);				
		       var mintime1=date; 
		       var minyear1=mintime1.getFullYear(); 
		       var mindate1=mintime1.getDate(); 
		       var minhour1=mintime1.getHours(); 
		       var minmonth1=mintime1.getMonth()+1;
		       var minutes1=mintime1.getMinutes();
		       if(minutes1=="0")
		       {
		          minutes1="00";
		       }
		       var mintimstr1=minyear1+"-"+minmonth1+"-"+mindate1+" "+minhour1+":"+minutes1+":00";
			   $("#minutetimeval").val(mintimstr1);
			}); 
		    $("#label7btnxhour").click(function(){ 
			    var minutevaluetype=$('input[name="minutevaluetype"]:checked').val();
		       var minutetimeval=$("#minutetimeval").val();	
		       var date=new Date(minutetimeval);		       	       
				var t = date.getTime();
				t += minutevaluetype*60*1000;//秒
				date.setTime(t);				
		       var mintime1=date; 
		       var minyear1=mintime1.getFullYear(); 
		       var mindate1=mintime1.getDate(); 
		       var minhour1=mintime1.getHours(); 
		       var minmonth1=mintime1.getMonth()+1;
		       var minutes1=mintime1.getMinutes();
		       if(minutes1=="0")
		       {
		          minutes1="00";
		       }
		       var mintimstr1=minyear1+"-"+minmonth1+"-"+mindate1+" "+minhour1+":"+minutes1+":00";
			   $("#minutetimeval").val(mintimstr1);
			}); 

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页