【问题标题】:Change the date format for the showLastUpdateTime at the bottom of pages更改页面底部 showLastUpdateTime 的日期格式
【发布时间】:2021-08-14 12:47:00
【问题描述】:

我已经添加了

          showLastUpdateTime: true,

到我的docusaurus.config.js,日期显示在文档的底部,但格式是美国(这不适用于世界上的大多数国家)。我需要它是明确的,或者不是“错误的”:D

有谁知道我该如何改变这个?

【问题讨论】:

    标签: date format locale docusaurus


    【解决方案1】:

    我不相信您可以手动显式设置格式 - 它在后台使用默认的 Intl.DateTimeFormat constructor - 但是您可以通过将站点的基本语言环境设置为默认值以外的方式来操作它。

    为此,您需要利用i18n configuration - 将其添加到您的docusaurus.config.js

    i18n: {
      defaultLocale: 'en-GB',
      locales: ['en-GB']
    }
    

    en-GB 替换为您想要的区域设置,您会看到以该区域设置格式显示的日期,因此在英国它是dd/MM/yyyy

    【讨论】:

      猜你喜欢
      • 2017-02-23
      • 2011-06-05
      • 2016-11-22
      相关资源
      最近更新 更多