Date Formatting

The computeDate function can be used to calculate a date, or to change the displayed format of the date. The syntax of this function is:

{{computeDate '{
    "dateTrait": [User attribute], 
    "timePhrase": [Time phrase], 
    "outputFormat": [Output format]
    }'
}}

While the computeDate function can alter how dates are displayed, the format in which dates are sent to CrossEngage must remain the same: ISO8601 format in UTC (Coordinated Universal Time). This can be written as YYYY-MM-DD.

Property

Type

Description

dateTrait

string

Optional. The user attribute that is used for date formatting and calculations. If omitted, the value 'now' is used, which takes the system time at the time of dispatch. e.g user.[traits.birthday]

timePhrase

string

Required. The operation that is executed on the dateTrait. If you want to use the dateTrait directly, simply set the timePhrasee.g. +1 hour, +2 days. This attribute is required even if you wish to display the current date: to do so, simply set the time phrase equal to 0.

outputFormat

string

Required. The format the function should output. All common date formats are supported e.g. yyyy-MM-dd, dd/MM/yy.

Displaying the date 10 days from a user's birthday

For this example, we output the date 10 days from the User's birthday.

{{computeDate '{
    "dateTrait": "user.[traits.birthday]",
    "timePhrase": "+ 10 days", 
    "outputFormat": "yyyy-MM-dd"
    }'
}}

For example, if the User has his next birthday on 2022-01-01, it would compute the date 2022-01-11.

Last updated