如何修改Ghost.org博客的日期格式

Jam*_*lly 4 html date handlebars.js ghost-blog

我的Ghost.org博客显示日期为:

2013年11月4日

这是content\themes\{theme-name}\post.hbs通过以下方式控制的:

<time datetime="{{date format="YYYY-MM-DD"}}">
    {{date format='DD MMM YYYY'}}
</time> 
Run Code Online (Sandbox Code Playgroud)

我希望将其更改为不同的格式,例如Wednesday, 4th November 2013,我该怎么做?

Jam*_*lly 8

Ghost使用Moment.js输出日期.

从他们的显示格式文档中我们可以确定:

  • dddd 可以用来输出全天的名字;
  • MMMM 可用于输出完整的月份名称;
  • Do可用于以1st 2nd 3rd 4th...格式输出日期;
  • YYYY 可用于输出全年数字.

从中我们可以content\themes\{theme-name}\post.hbs使用以下方法制作我们想要的日期格式:

<time datetime="{{date format="YYYY-MM-DD"}}">
    {{date format='dddd, MMMM Do YYYY'}}
</time>
Run Code Online (Sandbox Code Playgroud)

2013年11月4日星期三