Format Filters
Format filters apply formats to specific types of data.
date
string | date: string
Converts a timestamp into a different date format.
The date filter uses parameters similar to Ruby's strftime method to format the date. For shorthand formats, consult Ruby's documentation or the strftime reference and sandbox.
The current date
You can use a date filter with keywords like 'now' and 'today' to display the current timestamp.
Note: The timestamp shows when the Liquid was last processed. It may not update with every page view due to caching and context.
format
string | date: format: string
Specify a locale-sensitive date format. You can utilize the following formats:
- abbreviated_date
- basic
- date
- date_at_time
- default
- on_date
- short (deprecated)
- long (deprecated)
Note: You can also specify personalized styles in your theme's local files.
Setting format options in locale files
You can create your own date formats in the locale files of your theme's storefront. These personalized formats should be categorized under "date_formats".
json
variable | json
Changes a string or object into JSON format.
Note: When using JSON output in JavaScript, you don't need to add quotes around it because the json filter already includes them. The json filter also handles escaping any quotes within the output.
Product inventory
When used on a product object in any Shopify store made after December 5, 2017, the JSON filter does not show the inventory_quantity and inventory_policy values for any related variants. These properties are hidden to prevent bots and crawlers from accessing inventory amounts for stores they shouldn't have access to.
structured_data
variable | structured_data
Changes an object into a schema.org data format.
The structured_data filter works on product and article objects.
Product objects are shown as a schema.org Product.
Article objects are shown as a schema.org Article.
weight_with_unit
number | weight_with_unit
Override the default unit
number | weight_with_unit: variable
You can choose a unit to replace the default one from the general settings.