Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello!
I am trying to create a section on our site that displays when an item was prepared, and also references an expiration date, which is 30 days later.
How exactly could this be done?
So far I have the following:
...
<span>Prepared: {{ created_at | date: "%B %d, %Y" }}</span>
...
Which outputs the date in the format February 22, 2022 (for example)
How can I easily make another line that says Expires: and adds 30 days to the above date?
I appreciate any assistance 🙂
Thanks
Solved! Go to the solution
This is an accepted solution.
Take a look at this:
https://www.huratips.com/tech-tips/how-to-add-days-to-date-in-shopify-liquid.html
{% 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" }}
This is an accepted solution.
Take a look at this:
https://www.huratips.com/tech-tips/how-to-add-days-to-date-in-shopify-liquid.html
{% 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" }}
Thank you very much!
That worked perfect.
for the assign date I just put {% assign date = created_at %} and it worked flawless.