How to compare dates in Shopify?

Enercos - Single Product eCommerce Shopify Theme

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: >, <, >=, <=.

You may also like...

Leave a Reply

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