如何获取当前周的数据

2023-12-13 10:51:10
 if (canSelectList?.length && tradeTime) {
          const sorter = canSelectList.sort((a, b) => a.toString() - b.toString());
          const weekDay = [7, 1, 2, 3, 4, 5, 6];
          const myDate = new Date(
              Date.parse(moment(tradeTime).format('YYYY/MM/DD'))
          );
          const index = sorter.findIndex((item) => item.toString() === tradeTime);
          const day = weekDay[myDate.getDay()] - 1;
          const lastDate = moment(sorter[index - day]?.toString());
          setRef?.setTime([lastDate, moment(tradeTime)]);
          setDate({
              startDate: moment(lastDate).format('YYYY-MM-DD'),
              endDate: moment(tradeTime).format('YYYY-MM-DD'),
          });
      }

文章来源:https://blog.csdn.net/qq_45823368/article/details/134964866
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。