mirror of
https://github.com/kemko/liquid.git
synced 2026-01-04 09:15:41 +03:00
1.4 KiB
1.4 KiB
title, description
| title | description |
|---|---|
| date | Liquid filter that prints and formats dates. |
Converts a timestamp into another date format. The format for this syntax is the same as strftime. The input uses the same format as Ruby's Time.parse.
Input
```liquid {% raw %} {{ article.published_at | date: "%a, %b %d, %y" }} {% endraw %} ```Output
```text Fri, Jul 17, 15 ```Input
```liquid {% raw %} {{ article.published_at | date: "%Y" }} {% endraw %} ```Output
```text 2015 ```date works on strings if they contain well-formatted dates:
Input
```liquid {% raw %} {{ "March 14, 2016" | date: "%b %d, %y" }} {% endraw %} ```Output
```text {{ "March 14, 2016" | date: "%b %d, %y" }} ```To get the current time, pass the special word "now" (or "today") to date:
Input
```liquid {% raw %} This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}. {% endraw %} ```Output
```text This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}. ```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.