Date Filters
Filters for formatting and manipulating date and time values.
Give them a timestamp, such as post.timestamp, a date, such as date(), or a date string such as post.post_date_gmt or a date custom field stored as 2026-03-01. post.date is already formatted with the site's date format, with no time, as in Timber: to format a post date, write post.date('F j, Y') or post.timestamp|date('F j, Y').
A value made of digits only reads as a timestamp, as in Twig. Eight digits that make a date, such as an ACF date stored as 20260301, read as that date, as in Timber.
Formatting
| Filter | Arguments | Description |
|---|---|---|
date | format, timezone | Format date |
time_ago | to | Human-readable time difference |
date
Arguments:
format— PHP date format (default: WordPress date format setting)timezone— Timezone name, such as'Europe/Paris', orfalseto keep the date's own (optional)
{{ post.timestamp|date }} <!-- Uses WP setting -->
{{ post.timestamp|date('F j, Y') }} <!-- January 15, 2024 -->
{{ post.timestamp|date('Y-m-d') }} <!-- 2024-01-15 -->
{{ post.timestamp|date('m/d/Y') }} <!-- 01/15/2024 -->
{{ post.timestamp|date('H:i') }} <!-- 14:30 -->
{{ post.timestamp|date('g:i A') }} <!-- 2:30 PM -->
{{ post.timestamp|date('c') }} <!-- ISO 8601 -->
{{ post.timestamp|date('F j, Y', 'America/New_York') }}
{{ '2026-01-28T15:00:00+04:00'|date('H:i', false) }} <!-- 15:00 -->
date shows the time in the site's timezone, or the one you give, and translates month and day names, like WordPress wp_date(). With false, a date keeps its own timezone, as in Twig and Timber; a timestamp has none and shows the site's. An unknown timezone shows nothing.
An empty value, such as a custom field without value, shows today's date, as in Twig and Timber. To show nothing, test it first:
{{ post.meta('event_date') is empty ? '' : post.meta('event_date')|date('F j, Y') }}
time_ago
Returns human-readable time difference ("3 days ago", "2 hours from now").
Arguments:
to— Compare to this date (default: current time)
{{ post.timestamp|time_ago }} <!-- 2 days ago -->
{{ post.modified_timestamp|time_ago }} <!-- 3 hours ago -->
{{ post.meta('event_date')|time_ago }} <!-- 5 days from now -->
A date string without offset reads as the site's time, as in Timber: use post.timestamp rather than post.post_date_gmt.
Date Modification
| Filter | Arguments | Description |
|---|---|---|
date_modify | modifier | Modify date |
An empty value starts from now, as in Twig.
Modifier examples:
'+1 day','-1 week','+1 month','+1 year''next monday','last friday''first day of this month','last day of this month'
{{ post.timestamp|date_modify('+1 day')|date('F j, Y') }}
{{ post.timestamp|date_modify('+1 week')|date('F j, Y') }}
{{ post.timestamp|date_modify('-2 weeks')|date('F j, Y') }}
{{ post.timestamp|date_modify('next monday')|date('F j, Y') }}
{{ post.timestamp|date_modify('first day of this month')|date('F j, Y') }}
Format Codes
Date
| Code | Description | Example |
|---|---|---|
Y | 4-digit year | 2024 |
y | 2-digit year | 24 |
m | Month (01-12) | 01 |
n | Month (1-12) | 1 |
F | Full month name | January |
M | Short month name | Jan |
d | Day (01-31) | 15 |
j | Day (1-31) | 15 |
D | Short weekday | Mon |
l | Full weekday | Monday |
Time
| Code | Description | Example |
|---|---|---|
H | Hour 24h (00-23) | 14 |
G | Hour 24h (0-23) | 14 |
h | Hour 12h (01-12) | 02 |
g | Hour 12h (1-12) | 2 |
i | Minutes (00-59) | 30 |
s | Seconds (00-59) | 45 |
A | AM/PM | PM |
a | am/pm | pm |
Other
| Code | Description | Example |
|---|---|---|
U | Unix timestamp | 1705330245 |
c | ISO 8601 | 2024-01-15T14:30:45+00:00 |
Common Patterns
Publication date
{{ post.date('F j, Y') }}
Relative time
{{ post.timestamp|time_ago }}
Datetime attribute
<time datetime="{{ post.timestamp|date('c') }}">
{{ post.date('F j, Y') }}
</time>
Expiry calculation
{{ post.meta('event_date')|date_modify('+30 days')|date('F j, Y') }}