This page shows how to use Liquid with date and time attributes in Blueshift. You'll find examples for birthdays, anniversaries, days since an event, countdowns, and formatting.
All examples are verified for Blueshift's Liquid syntax and supported filters.
On this page
- Birthday personalization
- Anniversary personalization
- Days since last app open
- Days since a custom event
- Days until a future event
- Add or subtract days
- Date formatting
Birthday personalization
Show a celebratory greeting on the exact birthday or a reminder before it.
Liquid:
{% if user.extended_attributes.date_of_birth %}
{% if (user.extended_attributes.date_of_birth | date: "%m-%d")
== (now | date: "%m-%d") %}
Happy birthday, {{ user.firstname }}! 🎂
{% elsif (user.extended_attributes.date_of_birth | date: "%m")
== (now | date: "%m")
and (user.extended_attributes.date_of_birth | date: "%d")
> (now | date: "%d") %}
Your special day is coming up, {{ user.firstname }}. 🎉
{% endif %}
{% endif %}
Example data:
{
"user": {
"firstname": "John",
"extended_attributes": { "date_of_birth": "1990-08-26" }
}
}
Anniversary personalization
Display content on a signup or subscription anniversary.
Liquid:
{% if user.extended_attributes.signup_date
and (user.extended_attributes.signup_date | date: "%m-%d")
== (now | date: "%m-%d") %}
Happy anniversary with us!
{% endif %}
Example data:
{
"user": { "extended_attributes": { "signup_date": "2022-08-26" } }
}
Days since last app open
Adjust copy based on how recently the user opened the app.
Liquid:
{% assign now_s = now | date: "%s" %}
{% assign last_s = user.extended_attributes.last_open_at | date: "%s" %}
{% if last_s %}
{% assign days = now_s | minus: last_s | divided_by: 86400 %}
{% if days <= 3 %}
Welcome back!
{% else %}
We miss you! See what's new.
{% endif %}
{% endif %}
Example data:
{
"user": { "extended_attributes": { "last_open_at": "2025-08-24T10:00:00Z" } }
}
Days since a custom event
Personalize content based on event recency.
Note: bsft_event_context is available only in event-triggered campaigns.
Liquid:
{% assign now_s = now | date: "%s" %}
{% assign last_evt_s = bsft_event_context.last_purchase_at | date: "%s" %}
{% if last_evt_s %}
{% assign days = now_s | minus: last_evt_s | divided_by: 86400 %}
{% if days <= 7 %}
Thanks for your recent purchase!
{% else %}
It's been a while—what can we help you find?
{% endif %}
{% endif %}
Example data:
{
"bsft_event_context": { "last_purchase_at": "2025-08-20T12:00:00Z" }
}
Days until a future event
Show a countdown message until an upcoming date stored on the user or event.
Liquid:
{% assign now_s = now | date: "%s" %}
{% assign end_s = user.extended_attributes.offer_expires_at | date: "%s" %}
{% if end_s %}
{% assign days_left = end_s | minus: now_s | divided_by: 86400 %}
{% if days_left > 0 %}
Only {{ days_left }} days left!
{% endif %}
{% endif %}
Example data:
{
"user": {
"extended_attributes": {
"offer_expires_at": "2025-08-30T00:00:00Z"
}
}
}
Add or subtract days
Compute a date N days from now and display it.
Liquid:
{% assign days = 5 %}
{% assign seconds = days | times: 86400 %}
{% assign future_s = now | date: "%s" | plus: seconds %}
Delivering by: {{ future_s | date: "%Y-%m-%d" }}
Example data:
{}
Date formatting
Render ISO dates in a friendly format. Convert timezone first if needed.
Note: time_zone is a Blueshift-specific filter.
Liquid:
{{ user.extended_attributes.renewal_date | date: "%B %e, %Y" }}
{%- comment -%} Or with timezone first {%- endcomment -%}
{{ user.extended_attributes.renewal_ts
| time_zone: 'Asia/Kolkata'
| date: "%B %e, %Y" }}
Example data:
{
"user": { "extended_attributes": { "renewal_date": "2025-12-01" } }
}
Comments
0 comments