Skip to main content

date

string | date: string
returns string

Converts a timestamp into another date format.

The date filter accepts the same parameters as Ruby's strftime method for formatting the date. For a list of shorthand formats, refer to the Ruby documentation or strftime reference and sandbox.

{{ article.created_at | date: '%B %d, %Y' }}

Output

April 14, 2022

You can apply the date filter to the keywords 'now' and 'today' to output the current timestamp.


Note

The timestamp will reflect the time that the Liquid was last rendered. Because of this, the timestamp might not be updated for every page view, depending on the context and caching.


{{ 'now' | date: '%B %d, %Y' }}

Output


string | date: format: string

Specify a locale-aware date format. You can use the following formats:

  • abbreviated_date
  • basic
  • date
  • date_at_time
  • default
  • on_date
  • short (deprecated)
  • long (deprecated)

Note

You can also define custom formats in your theme's locale files.


{{ article.created_at | date: format: 'abbreviated_date' }}

Output

Apr 14, 2022
Anchor to Setting format options in locale files

Setting format options in locale files

You can define custom date formats in your theme's storefront locale files. These custom formats should be included in a date_formats category:

"date_formats": {
"month_day_year": "%B %d, %Y"
}
{{ article.created_at | date: format: 'month_day_year' }}

Output

April 14, 2022
Was this page helpful?