• 根据指定日期获取 之后N 天日期和星期


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8" />
        <title>Document</title>
    </head>
    <body>
        
    </body>
    
            <script>
    
    var a='2020-02-28';//选择的日志
    
    const today = new Date(a)//以选择的日期 实例化一个时间对象
    
    var days=new Array();
    
      var Y = today.getFullYear() ;//
            var M = today.getMonth()+1; //
            if(M<10){
                M='0'+M;
            }
            var D = today.getDate() ;//
             if(D<10){
                D='0'+D;
            }
    
    days[0] = Y+'-'+M+'-'+D;   //放入数组
    for(var i=1;i<=14;i++){
    
    today.setDate(today.getDate() + 1)        //加上相应的天数
    
      Y = today.getFullYear() ;//
             M = today.getMonth()+1; //
             if(M<10){
                M='0'+M;
            }
    
             D = today.getDate() ;//
             if(D<10){
                D='0'+D;
            }
    
    days[i] = Y+'-'+M+'-'+D;   //放入数组     
    
    }
    alert(days);
    console.log(days);
    console.log(a);
    var weekarry=[];
    getWeek(days);
    function isNull(object){ 
        if(object == null || typeof object == "undefined"){ 
            return true; 
        } 
        return false; 
    };
    
    
    function getWeek(dateString){
        var date;
        if(isNull(dateString)){
            date = new Date();
        }else{
            for(let i=0;i<days.length;i++){
                 var dateArray = dateString[i].split("-");
                // console.log(dateArray);
                date = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
    
                 weekarry.push("星期" + "日一二三四五六".charAt(date.getDay()));
            }
            alert(weekarry);
           
        }
        //var weeks = new Array("日", "一", "二", "三", "四", "五", "六");
        //return "星期" + weeks[date.getDay()];
       
    };
    
    
    </script>
    
    
    </html>
  • 相关阅读:
    申论1
    why factory pattern and when to use factory pattern
    jvm的字符串池
    is assembler instruction and machine instuction atomic
    jvm本身的多线程机制
    final
    java类的加载
    path和classpath的用途
    jar -cmf file1 file2 file3命令
    MANIFEST.MF中的MF是什么意思
  • 原文地址:https://www.cnblogs.com/jinsuo/p/12931547.html
Copyright © 2020-2023  润新知