Skip to content

Formatter

The Formatter is a built-in integration, so there is no account to connect. Its actions take a value (typed text or a token from earlier in the recipe), change its format, and hand the result to later actions as a token: a date turned into a timestamp, a product name in uppercase, a price rounded to two decimals. The Formatter requires Uncanny Automator Pro.

Five actions appear under Formatter in the recipe builder’s picker, each with the Pro label:

  • Convert date into format
  • Extract the first word from a string
  • Convert number into format
  • Replace values in a string
  • Convert text into format

The three Convert actions are the ones with a choice of output format; their options are listed below. To add any of them, click the + at the end of the recipe’s flow, search for Formatter in the picker, select the action, fill in the Set up step, and click Save. Formatter actions have no Test step.

The example below uses Convert date into format. Its Input holds a date token from the trigger, here the user’s registration date. Input format is left on Automatic format recognition (recommended), which lets Automator detect the format and is what we recommend. Output format is set to Unix timestamp, and the dropdown shows a sample of each format.

The Set up step of the Formatter date action with the User registered date token as Input, Automatic format recognition (recommended) as Input format, and Unix timestamp as Output format

Supported output formats

Date output formats

Convert date into format accepts any value that holds a date and can output it as:

  1. Mmm DD, YYYY
  2. MM/DD/YYYY
  3. MM/DD/YY
  4. DD/MM/YY
  5. DD/MM/YYYY
  6. ISO 8601
  7. RFC 2822
  8. Unix timestamp
  9. The day of the month (from 01 to 31)
  10. A textual representation of a day (three letters)
  11. The day of the month without leading zeros (1 to 31)
  12. A full textual representation of a day
  13. Simple time (12 hour format)
  14. Time with seconds (12 hour format)
  15. Simple time (24 hour format)
  16. Time with seconds (24 hour format)
  17. Timezone offset in seconds
  18. Timezone abbreviation
  19. Difference to Greenwich time (GMT) in hours:minutes
  20. Difference to Greenwich time (GMT) in hours
  21. Whether the date is in daylight saving time (1 if Daylight Saving Time, 0 otherwise)
  22. The ISO-8601 numeric representation of a day (1 for Monday, 7 for Sunday)
  23. A full textual representation of a month (January through December)
  24. A numeric representation of a month (from 01 to 12)
  25. A short textual representation of a month (three letters)

Text output formats

Convert text into format offers:

  1. Uppercase
  2. Lowercase
  3. Title case
  4. Capitalize first letters in words
  5. Escape HTML
  6. Remove HTML
  7. Trim spaces around the string
  8. Shuffle
  9. Reverse
  10. Slugify
  11. Character count
  12. Word count
  13. md5 hash
  14. sha256 hash
  15. Nonce create
  16. URL encode
  17. URL decode
  18. Extract Email address
  19. Extract URL
  20. Remove spaces

Number output formats

Convert number into format offers:

  1. Round to integer
  2. Round to one decimal place
  3. Round to two decimal places
  4. Currency English notation (1,234.56)
  5. Currency French notation (1 234,56)
  6. Currency with dot decimals (1 234.56)
  7. Round down (floor)
  8. Round up (ceil)
  9. Is even (returns 1 for even values, 0 for odd)
  10. Default zero (replace empty value with zero)

Using formatted data in a recipe

A Formatter action’s result is available to the actions after it as an action token. Action tokens are filled in only once the action that produces them has run, so keep each Formatter action above the action that uses its output; actions run in the order they appear on the canvas (see Managing actions).

Suppose you want to add one full day (24 hours) to a date that comes from the trigger, such as a date field in a submitted form or the user’s registration date, and store the result in user meta in the “Mmm DD, YYYY” format. That takes three actions:

  1. A Convert date into format action turns the date token into a Unix timestamp, with Input format left on automatic recognition. A timestamp is a whole number of seconds, so the next step can do arithmetic on it. The action’s result is a token named Output.

The first Formatter action, reopened after saving, converting the User registered date token into a Unix timestamp

  1. A second Convert date into format action takes a Calculation token as its input. Click the ∗ button in Input, open the Global tab, then Advanced > Calculation. In the Formula field of the Calculation dialog, insert the first action’s Output token, type + 86400 (the seconds in a day), and click Save. Set Output format to Mmm DD, YYYY, which returns the date to a readable form.

The second Formatter action with a Calculation token of the first action's Output plus 86400 as Input, and Mmm DD, YYYY as Output format

  1. A WordPress Core Set user meta action (Pro) saves the second action’s Output token to a meta key. In its Meta table, enter the Key, here modified_submission_date, and insert the token as the Value. Both Formatter actions name their token Output, so pick it from the second action’s group in the token picker; a Custom action label on each Formatter action makes the two easier to tell apart.

The Set up step of the WordPress Core Set user meta action with the key modified_submission_date and an Output token as the value in the Meta table

When the recipe runs, the date is converted, a day is added, and the new date is stored in user meta in the “Mmm DD, YYYY” format.

Related: Managing tokens, Calculations and math equations, Managing actions

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top