Date to Text

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

Input

Field Definition Type Required
start Date and time value to be formatted. Date & Time TRUE
format Date format code of the input value for the start field such as M/D/Y to produce 9/7/2016 or hh:mm a for a time such as 09:05 am. See below for format codes. String TRUE
zone A TZ time zone such as US/Pacific or Europe/Paris. String TRUE

Output

Field Definition Type
output Text of the date in the chosen format in the designated timezone. String

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).

Examples

If the ISO start date is 2016-09-07T00:01:25.670Z and zone is America/Pacific then:

format output
M/D/Y

9/6/2016

h:mm a z 9:01 am PDT
dddd, MMMM D, Y Wednesday, September 7, 2016
D-MMM-YY HH:mm:ss.S z 7-Sep-16 09:01:25.6 PDT

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

Related topics

Functions in Workflows

About the elements of Okta Workflows