date_add - Liquid Filter Reference - 1.0.0

Filter Name date_add
Group Dates
Version 1.0.0

Description

Adds a unit of time to a date and returns a datestamp in UTC. Valid units are: years, months, weeks, days, hours, minutes, and seconds

Examples

When the unit is days, it adds the provided number of days to the supplied date:
{{ "2021-03-01T09:00:00" | date_add: days: 5 }}
2021-03-06T09:00:00Z
When the unit is minutes, it adds provided number of minutes to the supplied date:
{{ "2021-03-01T09:00:00" | date_add: minutes: 5 }}
2021-03-01T09:05:00Z
When the unit is weeks and the number is 5, it adds provided number of weeks to the supplied date:
{{ "2021-03-01T09:00:00" | date_add: weeks: 5 }}
2021-04-05T09:00:00Z
When with a non-UTC timestamp, it converts datetime to UTC:
{{ "2021-03-01T09:00:00+10:00" | date_add: days: 5 }}
2021-03-05T23:00:00Z
When the unit value is negative, it subtracts the provided number of units from the supplied date:
{{ "2021-03-01T09:00:00" | date_add: days: -5 }}
2021-02-24T09:00:00Z

Back to Filter List

Back to Liquid Reference for 1.0.0

 

 
Back to Documentation