js/ts/tsx读取excel表格中的日期格式转换

  const formatDate = (timestamp: number) => {
    const time = new Date((timestamp - 1) * 24 * 3600000 + 1);
    time.setFullYear(time.getFullYear() - 70);
    const year = time.getFullYear();
    const month = time.getMonth() + 1;
    const date = time.getDate() - 1;
    const format = '-';
    return (
      year + format + (month < 10 ? `0${month}` : month) + format + (date < 10 ? `0${date}` : date)
    );
  };

 

你可能感兴趣的:(js/ts/tsx读取excel表格中的日期格式转换)