Jekyll日期格式如何工作? [英] How does Jekyll date formatting work?

查看:206
本文介绍了Jekyll日期格式如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jekyll生成一个简单的网站.

I'm using Jekyll to generate a simple site.

我希望日期字段以12 September 2011格式显示.

I want the date field to display in the format 12 September 2011.

通过一些创造性的搜索,我发现了一些日期格式的操作,但是似乎没有什么让我知道月份的名称.我所拥有的是{{ page.date| date: "%m-%d-%Y" }},它可以将我输出为09-12-2011,但并不是我想要的.

I've found, through some creative googling, a bit of date-format manipulation, but nothing that seems to get me the month name. What I have is {{ page.date| date: "%m-%d-%Y" }}, which gets me output as 09-12-2011, but isn't quite what I'm looking for.

有什么方法可以在Jekyll中获得月份的名称吗?

Is there any way to get the month as a name in Jekyll?

或者,除此以外,是否有有关date属性的文档?

Or, barring that, is there any documentation for the date attribute?

推荐答案

解决方案

此输出过滤器:

Solution

This output filter:

{{ page.date | date: "%-d %B %Y" }}

生成日期格式如下:

9 September 2013

请确保当天不要错过%-d前面的减号(-).没有它,低于10的数字将带有前导零(例如09 September 2013).

Be sure not to miss the minus (-) in front of %-d for the day. Without it, numbers below ten would have leading zeros (e.g. 09 September 2013).

有关各个日期格式标记的详细信息,请参见流动的输出标签和过滤器"文档页面.

Details on the individual date formatting tokens can be found on the Liquid "Output tags and filters" documentation page.

我整理了一个大型的Jekyll日期格式化示例.它提供了几种格式的示例,并应提供足够的详细信息以您想要的任何方式进行格式化.一些示例包括:

I put together a large set of Jekyll date formatting examples. It provides examples for several formats and should provide enough detail to format in any way you'd like. Some examples include:

  • 2013-09-23
  • 2013年9月23日
  • 9月. 2013年23月23日
  • 2013年7月4日(即,将名称更改为"Juli"之类的其他语言,而不是"July").

享受!

这篇关于Jekyll日期格式如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆