Using ESL you can perform date transformations - whatever is convenient for your campaign. Providing a 3-day deadline for a sale, for example.
PARAMETER | FORMAT |
---|---|
Date field + Modify filter | {{contact.1111|localized_date('en-US', 'full')}} |
Today's Date | {{ "now" | localized_datetime("en-US", "full") }} |
3 Days in the Past | {{ "-3 days" | localized_datetime("en-US", "full") }} |
3 Days in the Future | {{ "3 days" | localized_datetime("en-US", "full") }} |
{% if 'now' | localized_date('de','yy') is even %}
Now: even years
{% elseif 'now' | localized_date('de','yy') is odd %}
Now: odd years
{% else %}
Now: nothing above
{% endif %}
For further details, see the localized date filter.
Displaying dates by specifying only the number of days
You can display dates by specifying only the number of days from the given date. In this case, you need to use a custom field where you store the date. In the following example, contact.12345
is a custom field where we store dates.
For example:
{{contact.12345|date_modify('+37 days')|date('d/m/y')}}
Displaying past or future dates
If you’d like to specify a timeframe for a contact, for example to redeem a voucher code, or to make a purchase, you can use the date_modify
filter.
For example:
In this use case we’ll grant our contact a voucher code that is only valid for the next 30 days.
{{ 'now' | date_modify("+30 day") | date("h:m:s m/d/Y") }}
The present date, "now" is recognised by the date handling process and it will always automatically update itself when the email is sent.
Here is an example of how the dates can be defined:
Example of how the dates are displayed for the contact:
If you’d like to specify a certain date in the future or in the past and it’s a fixed date, you can add the starting date with the following code snippet. This way you don’t need the date saved in a custom field.
{% set date = "11/27/2023" %}
{{ date | date_modify("+30 day") | date("h:m:s m/d/Y") }}
or
{% set date = "11/27/2023" %}
{{ date | date_modify("-30 day") | date("h:m:s m/d/Y") }}