Date Filters
Format dates and times using strftime patterns.
The date filter formats a date value into a readable string. It uses strftime format codes to control the output.
Basic usage
{{ product.created_at | date: '%B %d, %Y' }}Output: July 03, 2026
The format string uses codes that start with %. Each code is replaced with a part of the date.
Current date
Use the string 'now' to get the current date and time:
{{ 'now' | date: '%Y-%m-%d' }}Output: 2026-07-03
Format codes
Here are the most common codes:
| Code | Meaning | Example |
|---|---|---|
%Y | Four-digit year | 2026 |
%y | Two-digit year | 26 |
%m | Month as a number (zero-padded) | 07 |
%B | Full month name | July |
%b | Short month name | Jul |
%d | Day of the month (zero-padded) | 03 |
%e | Day of the month (space-padded) | 3 |
%A | Full weekday name | Thursday |
%a | Short weekday name | Thu |
%H | Hour in 24-hour format | 14 |
%I | Hour in 12-hour format | 02 |
%M | Minutes | 30 |
%S | Seconds | 45 |
%p | AM or PM | PM |
%Z | Time zone name | UTC |
%% | A literal % character | % |
Common patterns
Date only
{{ order.created_at | date: '%d %B %Y' }}Output: 03 July 2026
Date and time
{{ order.created_at | date: '%d %b %Y at %H:%M' }}Output: 03 Jul 2026 at 14:30
ISO 8601
Useful for <time> elements and structured data:
<time datetime="{{ product.created_at | date: '%Y-%m-%dT%H:%M:%S%z' }}">
{{ product.created_at | date: '%B %d, %Y' }}
</time>Short date
{{ order.created_at | date: '%d/%m/%Y' }}Output: 03/07/2026
Month and year
{{ article.published_at | date: '%B %Y' }}Output: July 2026
time_tag
Generate a semantic HTML <time> element with the correct datetime attribute:
{{ product.created_at | time_tag }}Output:
<time datetime="2026-07-03T14:30:00Z">July 03, 2026</time>Pass a format string to control the visible text:
{{ order.created_at | time_tag: '%d %b %Y' }}Output:
<time datetime="2026-07-03T14:30:00Z">03 Jul 2026</time>The datetime attribute always uses ISO 8601 format, regardless of the display format you choose. This helps search engines and screen readers understand dates correctly.
Tips
The date filter works with any value that represents a date. This includes ISO 8601 strings, Unix timestamps, and date objects from the platform.
If the input value is not a valid date, the filter returns the input unchanged. It does not throw an error.
Plain text around the format codes is kept as-is:
{{ order.created_at | date: 'Placed on %B %d, %Y' }}Output: Placed on July 03, 2026