Date to Text

Formats a date and time into a provided format in a specified timezone.

Input Fields

  • start - the date and time you wish to format

  • format - a date format code that indicates how to display the date and/or time, such as "M/D/Y" to get a result like "9/7/2016" or "hh:mm a" for a time like "09:05 am" (see table below for list of acceptable format codes)

  • zone - a "TZ" time zone such as "US/Pacific" or "Europe/Paris" (see full list on wikipedia).

Output Fields

  • output - the text of the date in the chosen format in the designated timezone

Format Codes

Build the format for the date and/or time format you want using any combination of the following codes along with fixed characters like slashes and commas:

  • D for day number (in the month) or DD to always show it using two digits

  • M for month number or MM for always two digits

  • MMM for three letter month name abbreviation or MMMM for full month name

  • Y for four digit year number or YY for two-digit year number

  • h for hour number (1-12) or hh to always show it using two digits

  • H for hour number (0-23) or HH to always show it using two digits

  • mm for minutes

  • ss for seconds (and add S's to include milliseconds, e.g. "ss.SSS")

  • a for "am" or "pm" or A for "AM" or "PM"

  • Z for timezone in offset format (e.g. "-07:00") or z for code (e.g. "PDT")

  • d for day of the week (1=Monday), ddd for day abbreviation (e.g. "Mon") or dddd for full day name (e.g. "Monday")

Examples If the ISO date is 2016-09-07T00:01:25.670Z and zone is "US/Pacific" then:

  • format "M/D/Y" results in output "9/6/2016"

  • format "h:mm a z" results in output "9:01 am PDT"

  • format "dddd, MMMM D, Y" results in output "Wednesday, September 7, 2016"

  • format "D-MMM-YY HH:mm:ss.S z" results in output "7-Sep-16 09:01:25.6 PDT"

If you want to format the current date and time, use a Now card and drag/drop the date field from the Now card into the start field on the Date To Text card.

See Also

Functions

About the elements of Okta Workflows