How to add days to date in Shopify liquid
Are you want to add days to date? Here is the solution to add days to the current date or desired date using Shopify liquid.
Add days to date
The following source code will add 5 days to date.
1 2 3 | {% assign date = '2015-04-20' | date: '%s' %} {% assign seconds = 5 | times: 24 | times: 60 | times: 60 %} {{ date | date: "%s" | plus: seconds | date: "%Y-%m-%d" }} |
Result: 2015-04-25
Add days to current date
The following source code will add 5 days to current date.
1 2 | {% assign seconds = 5 | times: 24 | times: 60 | times: 60 %} {{ 'now' | date: "%s" | plus: seconds | date: "%Y-%m-%d" }} |
Why do the math like that when you can just assign the seconds?
For 30 days, google how man seconds in 30 days
{% assign seconds = 2592000 %} yeilds same results, and much simpler.
How would you add business days to liquide code?