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

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" }
  }
}
Rendered output (on Aug 26): Happy birthday, John! 🎂

Back to TOC ↑

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" } }
}
Rendered output: Happy anniversary with us!

Back to TOC ↑

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" } }
}
Rendered output: Welcome back!

Back to TOC ↑

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" }
}
Rendered output: Thanks for your recent purchase!

Back to TOC ↑

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" 
    } 
  }
}
Rendered output: Only 4 days left!

Back to TOC ↑

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:

{}
Rendered output: Delivering by: 2025-08-31

Back to TOC ↑

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" } }
}
Rendered output: December 1, 2025

Back to TOC ↑

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.