当前位置:网站首页>Time processing logic for the last 7 days, the last 10 days, and the last 90 days

Time processing logic for the last 7 days, the last 10 days, and the last 90 days

2022-06-11 16:09:00 imkaifan

 //  Get and format time parameters 
    getTimeParams(t) {
    
      let endDate = new Date();
      let startDate = new Date(endDate.getTime() - (t * 24 * 60 * 60 * 1000));
      let startYear = startDate.getFullYear();
      let endYear = endDate.getFullYear();
      let startMonth = (startDate.getMonth() + 1) < 10 ? `0${
      startDate.getMonth() + 1}` : (startDate.getMonth() + 1);
      let endMonth = (endDate.getMonth() + 1) < 10 ? `0${
      endDate.getMonth() + 1}` : (endDate.getMonth() + 1);
      let startDay = startDate.getDate() < 10 ? `0${
      startDate.getDate()}` : startDate.getDate();
      let endDay = endDate.getDate() < 10 ? `0${
      endDate.getDate()}` : endDate.getDate();
      this.timeQuery.beginTime = `${
      startYear}-${
      startMonth}-${
      startDay}T00:00:00+08:00`;
      this.timeQuery.endTime = `${
      endYear}-${
      endMonth}-${
      endDay}T23:59:59+08:00`;
    },
原网站

版权声明
本文为[imkaifan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111551493180.html