Date_plus not working in custom liquid code?

According to the documentation here ( Scroll down to Filters, https://help.shopify.com/en/manual/shopify-flow/concepts/variables) you can add 1 year to a date using the date_plus filter but I can’t get that to work.

This feels like a dumb question but I copied the reference exactly and it is not working. What am I doing wrong??? This is in a Custom.liquid section on a page of my dev site.

I can add a year using this code…

{% assign more_time = 365 | times: 24 | times: 60 | times: 60 %}
{{ 'now' | date: "%s" | plus: more_time | date: "%Y-%m-%d" }}

…but I want a solution that takes leap years into account.

1 Like

Flow uses a different implementation of Liquid and you’re not doing it in Flow.
Theme Liquid does not have this filter.

1 Like

Just keep going?
{% assign more_time_lept = 365 | times: 24 | times: 60 | times: 60 %}
then check if year is every 4 years
:bomb: keeping in mind that if your doing this in a theme pages are cached so info like ‘now’ can be stale when there’s no data actually changing like a product property or metafield reference.

Mentioning flow it can be used for something like this to set a metafield using it’s special date filters.
This could also be done with the mechanic app. e.g. https://tasks.mechanic.dev/make-products-unavailable-after-the-date-time-stored-in-product-metafields
Then just reference the metafield instead of trying to build timestamps in liquid.