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)
    );
  };

 

posted @ 2020-06-26 23:56  lishidefengchen  阅读(699)  评论(0编辑  收藏  举报