formatDate
A Workflow Engine function that allows an epoch date (number of seconds since 1/1/1970 00:00:00) to be formatted using a set of predefined macros.
This function uses a set of macros to allow a date string to be constructed using the “atomized” parts of a date - hours, minutes, seconds, date, month, year, and other increments. The available macros are loosely based on a subset of those available from strftime()
C library.
This function is available as a feature of the Add-Ons v2.4.0 download and later.
This function is available for event, alert, and Situation workflows.
The workflow sweep up filter applies to this function.
Back to Workflow Engine Functions Reference.
Macro | Value |
---|---|
| The year in short form Example: "21" |
| The year in long form Example: "2021" |
| The day in short form Example: "Mon" |
| The day in long form Example: “Monday” |
| The month in short form Example: “Feb” |
| The month in long form Example: “February” |
| The day of the month Value range: 00-31 |
| Month number Value range: 01-12 |
| 24hr representation of the hour Value range: 00-24 |
| 12hr representation of the hour Value range: 00-12 |
| Minutes as a decimal Value range: 00-59 |
| “pm” or “am” |
| “PM” or “AM” |
| Seconds Value range: 00-59 |
| Day of the week Value range (1 = Monday, 2 = Tuesday, … 7 = Sunday) |
| Local timezone offset as a +/-hh:mm |
The above macros can be mixed with standard string characters. For example, to create a HH:MM:SS dd/mm/yy format, you would use:
%H:%M:%S %d/%m/%y
Arguments
Workflow Engine function formatDate
takes the following arguments:
Name | Required | Type | Description |
---|---|---|---|
| yes | string | The value to convert - using substitution (example: |
| yes | string | The format to convert to. |
| yes | string | The destination CEvent or workflow context field to populate with the conversion. |
Example
The following example demonstrates typical use of Workflow Engine function formatDate
.
To convert the agent_time for an incoming event to a human readable date:
formatDate
date
: $(agent_time)format
:%d %B %Y %H:%M:%S
destination
:custom_info.date
In the UI, this would look like:
{"date":"$(agent_time)","format":"%d %B %Y %H:%M:%S","destination":"custom_info.date"}
The resulting format would be:
"agent_time": 1640012988, ... "custom_info": { "date": "20 Decembmer 2021 15:09:48", ... }