Important Update
Looking for the Latest Documentation?
We've moved our documentation to a new home! Visit our official docs site for the most up-to-date guides, API references, and tutorials. The below docs are like old and out of date.
How to compare two time periods with Liquid
Earlier today, we were asked by Adam (of SleepHQ) in Discord about how to compare two dates in Liquid.
Specifically, he wanted to check if the user had signed up in the last few days so he could show a specific message in his broadcast.
Below is the snippet we used:
{%- assign date = 'now' | date: '%s' | minus: 345600 -%}
{%- assign signed_up_date = visitor.created_at | date: '%s' | minus: 0 -%}
{%- if date < signed_up_date -%}
Add your content here
{%- endif -%}