Skip to content

astro-paper主题

Published:

记录一下在使用astro-paper过程中遇到的问题

Table of contents

Open Table of contents

文章日期比pubDatetime多了8小时

这是因为astro在读取时间时,自动转成了UTC时间,需要指定UTC0时区

修改:

// src/components/Datetime.tsx
  const date = myDatetime.toLocaleDateString(LOCALE.langTag, {
    year: "numeric",
    month: "short",
    day: "numeric",
  });

  const time = myDatetime.toLocaleTimeString(LOCALE.langTag, {
    hour: "2-digit",
    minute: "2-digit",
  });
// 改成
  const date = myDatetime.toLocaleDateString(LOCALE.langTag, {
    year: "numeric",
    month: "short",
    day: "numeric",
    timeZone: "Europe/London"
  });

  const time = myDatetime.toLocaleTimeString(LOCALE.langTag, {
    hour: "2-digit",
    minute: "2-digit",
    timeZone: "Europe/London"
  });

Previous Post
网易云时间
Next Post
libgdx自定义模型加载器