Date filters can be used for date arithmetic or to convert DateTime values into various formats.

date

Formats a DateTime value using a .NET format string.

Code
{{ now | date: 'g' }}
{{ now | date: 'MMMM dd, yyyy' }}
Output
10/19/2018 10:56 PM
October 19, 2018

date_add_days Added 7.0.0011

Adds the specified number of whole and fractional days to the DateTime value. The parameter can be positive or negative.

Code
{{ now }}
{{ now | date_add_days: 1 }}
{{ now | date_add_days: -2.5 }}
Output
10/19/2018 10:56:21 PM
10/20/2018 10:56:21 PM
10/17/2018 10:56:21 AM

date_add_hours Added 7.0.0011

Adds the specified number of whole and fractional hours to the DateTime value. The parameter can be positive or negative.

Code
{{ now }}
{{ now | date_add_hours: 1 }}
{{ now | date_add_hours: -2.5 }}
Output
10/19/2018 10:56:21 PM
10/19/2018 11:56:21 PM
10/19/2018 8:26:21 PM

date_add_minutes Added 7.0.0011

Adds the specified number of whole and fractional minutes to the DateTime value. The parameter can be positive or negative.

Code
{{ now }}
{{ now | date_add_minutes: 10 }}
{{ now | date_add_minutes: -2.5 }}
Output
10/19/2018 10:56:21 PM
10/19/2018 11:06:21 PM
10/19/2018 10:53:51 PM

date_add_months Added 7.0.0011

Adds the specified number of whole months to the DateTime value. The parameter can be positive or negative.

Code
{{ now }}
{{ now | date_add_months: 1 }}
{{ now | date_add_months: -2 }}
Output
10/19/2018 10:56:21 PM
11/19/2018 10:56:21 PM
8/19/2018 10:56:21 PM

date_add_seconds Added 7.0.0011

Adds the specified number of whole and fractional seconds to the DateTime value. The parameter can be positive or negative.

Code
{{ now }}
{{ now | date_add_seconds: 10 }}
{{ now | date_add_seconds: -1.25 }}
Output
10/19/2018 10:56:21 PM
10/19/2018 10:56:31 PM
10/19/2018 10:56:20 PM

date_add_years Added 7.0.0011

Adds the specified number of whole years to the DateTime value. The parameter can be positive or negative.

Code
{{ now }}
{{ now | date_add_years: 1 }}
{{ now | date_add_years: -2 }}
Output
10/19/2018 10:56:21 PM
10/19/2019 10:56:21 PM
10/19/2016 10:56:21 PM

date_to_iso8601

Formats a DateTime value according to the ISO 8601 standard. Useful when creating Atom feeds, or the HTML5 <time> element.

Code
{{ now | date_to_iso8601 }}
Output
2018-10-19T22:56:21Z

date_to_rfc822

Formats a DateTime value according to the RFC 822 standard. Useful when creating RSS feeds.

Code
{{ now | date_to_rfc822 }}
Output
Fri, 19 Oct 2018 22:56:21 Z