• js计算日期增加


     <div class="time">
                <i class="visa_icon prev"></i><span id="dataTime">2018-6-27 </span> <span id="week" data-id=''>星期三</span><i class="visa_icon next"></i>
            </div>
    

      

     $(".next").on('click',function(){
    //    	next=true;
    //    	pre =false;
    //    	UpData(pre,next);
    //    	 date.yyyy = Number($('.year').text());
    //      date.mot = Number($('.month').text());
    //      date.dd  =Number($('.data').text());
    //    	var newDate = addDate(date,1).split("-");
    //    	if(newDate[1]<10){
    //    		newDate[1] = 0+newDate[1];
    //    	}
    //    	if(newDate[2]<10){
    //    		newDate[2] = 0+newDate[2];
    //    	}
    //    	$('.year').text(newDate[0])
    //      $('.month').text(newDate[1])
    //      $('.data').text(newDate[2])
            reckonTime(1)
          })
          $(".prev").on('click',function(){
    //    	next=false;
    //    	pre =true;
    //    	UpData(pre,next);
    //    	 date.yyyy = Number($('.year').text());
    //      date.mot = Number($('.month').text());
    //      date.dd  =Number($('.data').text());
    //    	var newDate = addDate(date,-1).split("-");
    //    	if(newDate[1]<10){
    //    		newDate[1] = 0+newDate[1];
    //    	}
    //    	if(newDate[2]<10){
    //    		newDate[2] = 0+newDate[2];
    //    	}
    //    	$('.year').text(newDate[0])
    //      $('.month').text(newDate[1])
    //      $('.data').text(newDate[2])
     		reckonTime(-1)
          })
    })
    //日历
    function reckonTime(num){
        var dataTime = $("#dataTime");
        var nowDataTime = dataTime.text();
        var arys1 = new Array();
        arys1 = addDate(nowDataTime,num).split('-');//显示的日期
        var ssdate = new Date(arys1[0], parseInt(arys1[1] - 1), arys1[2]);
        var  week1=String(ssdate.getDay()).replace("0","日").replace("1","一").replace("2","二").replace("3","三").replace("4","四").replace("5","五").replace("6","六");
        var myDate = new Date();
        var nowTime =myDate.toLocaleDateString();//获取今天日期
        var current_time = nowTime;
        var stop_time = addDate(nowDataTime,num);//
        console.log(addDate(nowDataTime,num))
        !CompareDate(current_time,stop_time) 
        && (dataTime.text(addDate(nowDataTime,num)),$("#week").text("星期"+week1));
    }
    function addDate(date,days){ 
        var d=new Date(date); 
        d.setDate(d.getDate()+days); 
        var m=d.getMonth()+1; 
        m = (m<10)?'0'+m:m;
        var da = d.getDate();
        da = (da<10)?'0'+da:da;
        return d.getFullYear()+'-'+m+'-'+da; 
    } 
    function CompareDate(d1,d2)
    {
      return ((new Date(d1.replace(/-/g,"/"))) > (new Date(d2.replace(/-/g,"/"))));
    }
    

      

  • 相关阅读:
    netcore---Program.cs配置相关信息,及读取配置信息
    js
    python3 openssl问题(贼有用)
    Flask+微信公众号开发(接入指南)
    运维角度处理跨域问题
    羞羞的Python模块包
    Nginx之伪404( root与alias )
    【深度学习】:梯度下降,随机梯度下降(SGD),和mini-batch梯度下降
    【深度学习】:小白也能看懂的卷积神经网络
    《剑指offer》5:替换空格
  • 原文地址:https://www.cnblogs.com/lst619247/p/9674188.html
Copyright © 2020-2023  润新知