Filters

Liquid Date Filters

Date Filters

Liquid date filters format Shopify dates with date and time.

Introduction to Liquid Date Filters

Liquid date filters are powerful tools in Shopify that allow developers to format date and time strings to enhance the display and functionality of store content. With these filters, you can transform raw date data into human-readable formats, adjust time zones, and customize the presentation according to the store's needs.

Basic Date Formatting

Liquid provides a number of date filters to format dates in a variety of ways. The most basic use is to output a date in a standard format such as YYYY-MM-DD. This is done using the date filter.

Customizing Date Formats

The date filter supports a wide range of formatting options using format specifiers. Here are some common ones:

  • %Y - Year with century
  • %m - Month (01..12)
  • %d - Day of the month (01..31)
  • %A - Full weekday name (e.g., Sunday)
  • %B - Full month name (e.g., January)

Handling Time Zones

Shopify's Liquid also allows you to adjust time zones using date filters. This is particularly useful for stores operating across multiple regions. By default, the Liquid engine uses the UTC time zone.

Using Date Filters with Variables

In addition to static dates, you can use Liquid date filters with variables. This allows dynamic date and time values to be formatted as needed.

For example, if you have a variable article.published_at containing a timestamp, you can format it as follows:

Conclusion

Liquid date filters provide a flexible way to format and manipulate date and time data in Shopify stores. By understanding and using these filters, developers can create a more engaging and user-friendly experience. Whether you're displaying blog post dates, customizing product launch times, or adjusting for time zones, Liquid date filters offer the tools you need to get the job done.