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:
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 |
| 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] |
| string | Required. The operation that is executed on the |
outputFormat | string | Required. The format the function should output. All common date formats are supported e.g. |
Displaying the date 10 days from a user's birthday
For this example, we output the date 10 days from the User's birthday.
For example, if the User has his next birthday on 2022-01-01, it would compute the date 2022-01-11.
Depending on how many characters are used, the dateformat is either single- or double digits, e.g. "yyyy-MM-dd" will result in a date with leading zeros for month and date (2022-01-11), "y-M-d" without leading zeros (2022-1-11).
The year is also a special case were "y", "yyy" and "yyyy" all output the full year (2022), wheras "yy" will output only the year of the century (22).
Please note that it lower-/uppercasing matters - dd
is not the same asDD,as
lower cased "dd" is the day of the month, whereas "DD" is the day of they year, e.g. the 1st of February is the 32nd day of the year.
Some examples (for 2024-05-10 14:15:55.978):
Symbol | Meaning | Example |
---|---|---|
Y/y | year of era/year | 2024 |
w | week of year | 19 |
E | day of week (text) | Fri |
e | day of week (num) | 5 |
d | day of month | 10 |
M | month of year | 5 |
m | minute of hour | 15 |
a | halfday of day (AM/PM) | PM |
K | hour of halfday (12h format) | 2 |
H | hour of day (24h format) | 14 |
s | second of minute | 55 |
S | fraction of second | 978 |
Last updated