Forum Discussion
Liquid using time of open conditions in email?
- 2 years ago
Hi Marc
Liquid is evaluated at the time an email is sent, so any time-based calculations are evaluated when the email is triggered and already rendered before the email is delivered. Even if you recorded the email open click, the email is already rendered in their inbox, so I'm struggling to see how it could be updated in real-time but I would love to know if others have workarounds, it's a great question.
For reference, some liquid that can determine the time of day would look something like the following:{% assign timeOfDay = 'now' | date: '%H' | plus: 0 %} {% if timeOfDay >= 0 and timeOfDay < 12 %} Good morning! {% else %} Good evening! {% endif %}
This assigns the current time 'now' to a variable, only keeping the current two-digit hour (%H), for example 02. Since this returns a string, we plus a 0 to that string. which turns the 02 into an integer that we can work with.
The if / else is then determining morning and evening based on that hour.
I hope that helps😊
Hi Marc
Liquid is evaluated at the time an email is sent, so any time-based calculations are evaluated when the email is triggered and already rendered before the email is delivered. Even if you recorded the email open click, the email is already rendered in their inbox, so I'm struggling to see how it could be updated in real-time but I would love to know if others have workarounds, it's a great question.
For reference, some liquid that can determine the time of day would look something like the following:
{% assign timeOfDay = 'now' | date: '%H' | plus: 0 %}
{% if timeOfDay >= 0 and timeOfDay < 12 %}
Good morning!
{% else %}
Good evening!
{% endif %}
This assigns the current time 'now' to a variable, only keeping the current two-digit hour (%H), for example 02. Since this returns a string, we plus a 0 to that string. which turns the 02 into an integer that we can work with.
The if / else is then determining morning and evening based on that hour.
I hope that helps😊
Related Content
- 28 days ago
- 2 years ago
- 2 years ago
- 2 months ago