//根据年月判断总共天数
      getDaysInMonth(year, month) {
         month = parseInt(month, 10); 
         var temp = new Date(year, month, 0);
         return temp.getDate();
      },
//根据年月日判断周次
     getWeek(year,month,day){
        month = parseInt(month, 10);         
        day = parseInt(day, 10); 
        let week = new Date(year+"/"+month+"/"+day).getDay();
        return week
     }
     //week:0=>周日     
     //week:1=>周一
     //week:2=>周二
     //week:3=>周三     
     //week:4=>周四
     //week:5=>周五     
     //week:6=>周六


格式转化

getYear()                //获取当前年份(2位)
getFullYear()            //获取完整年份(4位)
getMonth()               //获取当前月份(0-11,0代表1月)
getDate()                //获取当前日(1-31)
getDay()                 //获取当前星期(0-6,0代表星期天)
getTime()                //获取当前时间
getHours()               //获取当前小时数(0-23)
getMinutes()             //获取当前分钟数(0-59)
getSeconds()             //获取当前秒数(0-59)
toLocaleDateString()     //获取当前日期 '2020/10/11'
toLocaleString()         //获取当前日期与时间"2020/12/1 下午5:48:01"

用户bPbA4lM
103 声望9 粉丝