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 -%}