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

%y

The year in short form

Example: "21"

%Y

The year in long form

Example: "2021"

%a

The day in short form

Example: "Mon"

%A

The day in long form

Example: “Monday”

%b

The month in short form

Example: “Feb”

%B

The month in long form

Example: “February”

%d

The day of the month

Value range: 00-31

%m

Month number

Value range: 01-12

%H

24hr representation of the hour

Value range: 00-24

%h

12hr representation of the hour

Value range: 00-12

%M

Minutes as a decimal

Value range: 00-59

%p

“pm” or “am”

%P

“PM” or “AM”

%S

Seconds

Value range: 00-59

%u

Day of the week

Value range (1 = Monday, 2 = Tuesday, … 7 = Sunday)

%z

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

date

yes

string

The value to convert - using substitution (example: $(custom_info.myDate)

format

yes

string

The format to convert to.

destination

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",
        ...
    }