How can I add 30 days to a date variable in Liquid?

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:

…

Prepared: {{ created_at | date: ā€œ%B %d, %Yā€ }}

…

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 :slightly_smiling_face:

Thanks

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" }}
2 Likes

Thank you very much!

That worked perfect.

for the assign date I just put {% assign date = created_at %} and it worked flawless.