Fork me on GitHub

关于日期

// 2019年10月的格式转为201910
      const year = this.data.seleteTime.split("年")[0]
      let month = this.data.seleteTime.split("年")[1].split("月")[0]


 // 计算每个月的天数
      const thisDate = new Date(year, month, 0);
      // console.log(thisDate.getDate());
      const day = thisDate.getDate();

// 如果月份小于10  改为 01 格式
      if (month < 10) {
        month = "0" + month
        // console.log(month)
      }

//拼接每月第一天的时间为"20191001 00:00:00"
      beginDate: year + month + '01' + ' ' + '00:00:00', 

//拼接每月最后一天时间为"20191031 23:59:59"
        endDate: year + month + day + ' ' + '23:59:59' 

//截取日期 20191001
      const theDate = reqData.beginDate.split(' ')[0]

//截取时间  00:00:00
      const theEnd = reqData.endDate.split(' ')[0]

//将时间转为 2019-10-01
      var r = theDate.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3")

//判断指定日期为星期几
          var arys1 = new Array();
          arys1 = '2019-10-01'.signDate.split('T')[0].split('-'); //日期为输入日期,格式为 2013-3-10
          const ssdate = new Date(arys1[0], parseInt(arys1[1] - 1), arys1[2]);
          const week1 = String(ssdate.getDay()).replace("0", "日").replace("1", "一").replace("2", "二").replace("3", "三").replace("4", "四").replace("5", "五").replace("6", "六"); //就是你要的星期几
          const week = "星期" + week1; //就是你要的星期几

 

posted @ 2019-11-01 22:51  ssh__F  阅读(255)  评论(0编辑  收藏  举报