Modifier: relative

Returns a date difference in a nice, human readable, string format. This modifier will add a phrase after the difference value relative to the current date and the passed in date.

You can turn off the extra words “ago”, “until”, and so on by passing false as a parameter

The string will be localized into your current site locale.

past_date: October 1 2015
future_date: October 1 2019

{{ past_date | relative }}
{{ future_date | relative }}
{{ past_date | relative:false }}

2 years ago
9 months ago
2 years

Additional Reading

Learn how to use and chain modifiers in the Antlers template guide.

Last modified on August 13, 2018