Text to Date

Create a date and time from the contents of text according to a specified format.

For most standard formats, this function is not necessary. You can pass any standard date and time text into a date input and it will be converted automatically. This function is for non-standard or ambiguous formats, such that the value 2/1 might be read as 1-Feb or 2-Jan.

Input

Field Definition Type Required
start Text to be converted to a date and time value. String TRUE
format Date format code of the input value for the start field. String FALSE

Output

Field Definition Type
output Date object that corresponds to the start input value based on the specified format code. Date & Time

Format Codes

Build the format for the date and/or time format you want using any combination of these codes along with fixed characters such as slashes and commas.

format codes output

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; for example, ss.SSS).
a For am or pm or A for AM or PM.
Z For timezone in offset format (for example, -07:00) or z for code (for example, PDT).
d For day of the week (1=Monday), ddd for day abbreviation (for example, Mon) or dddd for full day name (for example, 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

start format output
1/2/2016 D/M/Y 2016-02-01T00:00:00.000Z
1/2/16 M/D/YY 2016-01-02T00:00:00.000Z
1493053116 X 2017-04-24T16:58:36.000Z

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

Related topics

Functions in Workflows

Elements of Workflows