Forum Discussion

Rajorigin's avatar
Rajorigin
Specialist
8 months ago

Liquid help to personalise dates as "today", "tomorrow" and yesterday

Hello friends,

Hope you are all well. I need some liquid help from you. We are using a date from the canvas_entry_property i.e. {{canvas_entry_properties}}.${{creation_date}} and we want to use the {{creation_date}} to personalise our messaging for example "thanks your account is active with us since "yesterday", from "today", or from "tomorrow" else for future dates we want to call the {{creation_date}} with a filter to represent the date as  27 Apr  etc. {{creation_date}} is in UTC format.

Appreciate some guidance here

Cheers

Raj

 

 

  • Hey Raj! Here's what I have so far. You'll most likely have to make format changes and also consider timezone differences. You can adjust the date inside "creation_date" to test different values.

     

    {% assign creation_date = "2024-04-27" %}
    {% assign creation_date_unix = creation_date | date: "%s" %}
    {% assign today_unix = "now" | date: "%F" | date: "%s" %}
    {% assign difference = creation_date_unix | minus: today_unix %}
    
    {% if difference < 0 %}
    Thank you for being a member with us since yesterday!
    {% elsif difference == 0 %}
    Thank you for being a member with us since today!
    {% elsif difference <= 86400 %}
    Thank you for being a member with us starting tomorrow!
    {% elsif difference > 86400 %}
    Thank you for being a member with us starting {{creation_date}}!
    {% endif %}

     

  • Hey Raj! Here's what I have so far. You'll most likely have to make format changes and also consider timezone differences. You can adjust the date inside "creation_date" to test different values.

     

    {% assign creation_date = "2024-04-27" %}
    {% assign creation_date_unix = creation_date | date: "%s" %}
    {% assign today_unix = "now" | date: "%F" | date: "%s" %}
    {% assign difference = creation_date_unix | minus: today_unix %}
    
    {% if difference < 0 %}
    Thank you for being a member with us since yesterday!
    {% elsif difference == 0 %}
    Thank you for being a member with us since today!
    {% elsif difference <= 86400 %}
    Thank you for being a member with us starting tomorrow!
    {% elsif difference > 86400 %}
    Thank you for being a member with us starting {{creation_date}}!
    {% endif %}