date

date

Converts a timestamp into another date format. The format for this syntax is the same as strftime.

Input

{{ article.published_at | date: "%a, %b %d, %y" }}

Output

Fri, Jul 17, 15

Input

{{ article.published_at | date: "%Y" }}

Output

2015

date works on strings if they contain well-formatted dates:

Input

{{ "March 14, 2016" | date: "%b %d, %y" }}

Output

Mar 14, 16

To get the current time, pass the special word "now" (or "today") to date:

Input

This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}.

Output

This page was last updated at 2017-06-22 14:49.

Note that the value will be the current time of when the page was last generated from the template, not when the page is presented to a user if caching or static site generation is involved.

© 2005, 2006 Tobias Luetke
Licensed under the MIT License.
https://shopify.github.io/liquid/filters/date/

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部