How to compare dates in Shopify?

Sell Online With Shopify
Trusted by millions of businesses worldwide
Sign up for a free trial and enjoy the first month of Shopify for $1.

In Shopify, the dates are strings so you can’t compare strings in the usual way. With Shopify liquid, you have to use the %s date filter to convert the date time to Unix epoch time.

The following source code will convert a specific day:

The following source code will convert current date:

And now you can use the operators: >, <, >=, <=.

Looking for Shopify Experts?

Hura Apps can help you take your store to the next level

Our team of experienced designers and developers can help you create a beautiful, high-converting Shopify store that will drive sales and increase customer satisfaction. From custom design to app development and optimization, we have the skills and expertise to help you achieve your eCommerce goals.

Get in touch

You may also like...

2 Responses

  1. Luis says:

    Thank you very much. It’s great.

  2. Gary M says:

    I believe it is still comparing timestamp STRINGS so any timestamp that starts with an number higher than today’s timestamp, even if it’s 50 years ago, will always be greater than today. Suggestion to use a secondary filter, plus: 0, that coerces the timestamp to an integer.

    {% assign today_date = 'now' | date: '%s' % | plus: 0 }

Leave a Reply

Your email address will not be published. Required fields are marked *