Text to Date

Creates a date & time from the contents of text, according to a format you specify. The specified format identifies the format of the 'start' input contents.

NOTE: For most standard formats, this function is not necessary. You can just pass any standard date & time text into a date input and it will convert automatically. This function is for non-standard or ambiguous formats (e.g. depending on the country of origin 2/1 might be 1-Feb or 2-Jan).

Input Fields

  • start – the text you want to convert to a date and time

  • format – a date format code that indicates the format of the start date input

Output Fields

  • output – the date object that corresponds to the provided text and format

Format Codes

Identify the format for the input 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”)

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

  • x for a timestamp in "unix in milliseconds" format, defined as the count of milliseconds since Jan 1 1970 at midnight GMT.

  • X for a timestamp in "unix in seconds" format, also known as "epoch" or "unix timestamp", which is defined as the count of seconds since Jan 1 1970 at midnight GMT.

Examples

  • If start is "1/2/2016" and format is "D/M/Y" then output is 2016-02-01T00:00:00.000Z

  • If start is "1/2/16" and format is "M/D/YY" then output is 2016-01-02T00:00:00.000Z

  • If _start _is "1493053116" and format is "X" then output is 2017-04-24T16:58:36.000Z

  • If you want to convert from a date from the Twilio connector, which uses RFC2822 format, set format to "ddd, DD MMM YYYY HH:mm:ss Z".  For example, that will convert a Twilio date of "Wed, 30 Nov 2016 03:17:37 +0000" to the Date format of "2016-11-30T03:17:37.000Z"

See Also

Functions in Workflows

About the elements of Okta Workflows