Skip to main content

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​

FilterArgumentsDescription
dateformat, timezoneFormat date
time_agotoHuman-readable time difference

date​

Arguments:

  • format — PHP date format (default: WordPress date format setting)
  • timezone — Timezone name, such as 'Europe/Paris', or false to 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​

FilterArgumentsDescription
date_modifymodifierModify 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​

CodeDescriptionExample
Y4-digit year2024
y2-digit year24
mMonth (01-12)01
nMonth (1-12)1
FFull month nameJanuary
MShort month nameJan
dDay (01-31)15
jDay (1-31)15
DShort weekdayMon
lFull weekdayMonday

Time​

CodeDescriptionExample
HHour 24h (00-23)14
GHour 24h (0-23)14
hHour 12h (01-12)02
gHour 12h (1-12)2
iMinutes (00-59)30
sSeconds (00-59)45
AAM/PMPM
aam/pmpm

Other​

CodeDescriptionExample
UUnix timestamp1705330245
cISO 86012024-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') }}