Built into Uncanny Automator rather than being an integration with a third party product, the Formatter action allows you to manipulate dates, text and numbers inside your recipes. The formatter can accept text or tokens as input, run formatting operations against the value and output the record in your choice of formats.
Here’s an example of the formatter action in use to convert a token passed in from a Gravity Form that contains a date in a text format. In this case, the action is able to recognize the format (we strongly recommend allowing Automator to recognize the date format on its own) and we’re choosing to output the date value as a timestamp.
Supported output formats
The Automator Formatter integration supports converting dates, numbers and text into other formats. Included below is a complete list of output options for each of the 3 Formatter actions.
Time output formats
Any value in some type of date structure can be converted into the formats:
- Mmm DD, YYYY
- MM/DD/YYYY
- MM/DD/YY
- DD/MM/YY
- DD/MM/YYYY
- ISO 8601
- RFC 2822
- Unix timestamp
- The day of the month (from 01 to 31)
- A textual representation of a day (three letters)
- The day of the month without leading zeros (1 to 31)
- A full textual representation of a day
- Simple time (12 hour format)
- Time with seconds (12 hour format)
- Simple time (24 hour format)
- Time with seconds (24 hour format)
- Timezone offset in seconds
- Timezone abbreviation
- Difference to Greenwich time (GMT) in hours:minutes
- Difference to Greenwich time (GMT) in hours
- Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise)
- The ISO-8601 numeric representation of a day (1 for Monday, 7 for Sunday)
- A full textual representation of a month (January through December)
- A numeric representation of a month (from 01 to 12)
- A short textual representation of a month (three letters)
Text output formats
The following conversion options are available for text inputs:
- Uppercase
- Lowercase
- Title case
- Capitalize first letters in words
- Escape HTML
- Remove HTML
- Trim spaces around the string
- Shuffle
- Reverse
- Slugify
- Character count
- Word count
- md5 hash
- sha256 hash
- Nonce create
- URL encode
- URL decode
- Extract Email address
- Extract URL
- Remove spaces
Number output formats
The following transformations can be performed on number inputs:
- Round to integer
- Round to one decimal place
- Round to two decimal places
- Currency English notation (1,234.56)
- Currency French notation (1 234,56)
- Currency with dot decimals (1 234.56)
- Round down (floor)
- Round up (ceil)
- Is even (returns 1 for even values, 0 for odd)
- Default zero (replace empty value with zero)
Using formatted data in a recipe
Input values that are converted to another format using the Formatter are available for use in recipes as action tokens.
Suppose we want to take a value entered in an “Mmm DD, YYYY” format in a form, add 100 days to it, then store the calculated value back to a user meta record in the original date format. The process to do that would look like this:
- First, we need to take the entered date value from the form (using a trigger token) and converted it into a timestamp. Why a timestamp? Because as an integer, we can perform math operations to add the 100 days to the value. The action would look like this:
- Now we want to add 100 days to the returned value. To do that, we can use the Calculation token inside the second Formatter action’s input field. Notice how we’re using the output of the Formatter as a token, adding 86400 to it (100 days in seconds, since the timestamp is a value in seconds), then passing the calculated value to the formatter.
- Finally, we’ll save the reformatted value in a user meta key we’ll call modified_submission_date, which uses the output of the second Formatter:
Now, when the form is submitted, the date will be converted, 100 days will be added, and the updated date record will be stored in user meta in the original format.