Format Date

This activity allows you to convert a date time to various different pre-defined or custom formats. This is often used when an API requires date times to be in a specific format that is different than the native format Automation uses.

Usage

The input expected by this activity will vary depending on whether you are using a default or custom date format. In either case, you need to provide the Output DateTime String Format and the Original Datetime to convert. You can enter the date manually or from a DateTime variable.

To convert to one of the default date formats, click the Output DateTime String Format drop-down menu and choose the format. If you want to use a custom format, check the Use Custom Datetime Format check box and enter the format you want to use.

Note: When using the variable browser to select this activity’s output, be careful which variable you select. Every activity has a Start time and End time which represents when the activity itself started and stopped running. The output from the activity is in the Result variable.

Supported Date Formats

The following datetime formats can be used as input into this activity. You can also use a DateTime variable.

Format Name Example
ANSIC Mon Jan 2 15:04:05 2018
UnixDate Mon Jan 2 15:04:05 MST 2018
RubyDate Mon Jan 02 15:04:05 -0700 2018
RFC822 02 Jan 18 15:04 MST
RFC822Z 02 Jan 18 15:04 -0700
RFC850 Monday, 02-Jan-18 15:04:05 MST
RFC1123 Mon, 02 Jan 2018 15:04:05 MST
RFC1123Z Mon, 02 Jan 2018 15:04:05 -0700
RFC3339 2018-01-02T15:04:05-07:00
RFC3339Nano 2018-01-02T15:04:05.999999999-07:00
Custom Formats - 2018-01-02
- 02-01-2018
- 20180102-150405
- 02012018-150405 (European time format)
Note: In European time format, 01 always stands for Month and 02 stands for Day.

Custom Datetime Formats

You can define a custom DateTime format in the Format Date and Parse Date activities. Use the placeholder values defined below to create your own format. The elements used in the Custom DateTime Format and Original DateTime fields must match.

Value Name Example
LongMonth January
Month Jan
NumMonth 1
ZeroMonth 01
LongWeekDay Monday
Weekday Mon
Day 2
UnderDay _2
ZeroDay 02
Hour 15
Hour12 3
ZeroHour12 03
Minute 4
ZeroMinute 04
Second 5
ZeroSecond 05
LongYear 2018
Year 18
PM PM
pm pm
TZ MST
ISO8601TZ Z0700
ISO8601SecondsTZ Z070000
ISO8601ShortTZ Z07
ISO8601ColonTZ Z07:00
ISO8601ColonSecondsTZ Z07:00:00
NumTZ -0700
NumSecondsTz -070000
NumShortTZ -07
NumColonTZ -07:00
NumColonSecondsTZ -07:00:00
FracSecond0 .0, .00, .000
FracSecond9 .9, .99, .999

Here are some examples of custom formats and what input would be expected for December 1st, 2020 at 10:30 PM:

Custom Format Expected Input
January 01, 2018 03:04:05 PM December 01, 2020 10:30:00 PM
2 Jan 2018 15:04:05 1 Dec 2020 22:30:00
01-02-2018 12-01-2020
15:04:05 22:30:00

Sample Workflows

The following sample workflows are available in our repository’s workflows folder to help you get familiar with this concept. These can be imported using the instructions in Import Git Content or you can click the workflow to view it in GitHub.