Connectors / Helper / Date & Time Helpers

Manipulate date and time values of various formats (updated: 1507802651695)

Date & Time Helpers

The Date & Time helpers allow you to manipulate date and time values of various formats from connectors and triggers.

Overview

The Date & Time helpers allow you to manipulate date and time values of various formats from connectors and triggers. These are commonly used for tasks such as converting date/time values to different formats, or finding the difference between two date & time values.

Examples

Getting the current day of the week

Step 1 - Get the current date and time

In this example, we'll be getting the current day of the week. The first thing we need to do is establish the current date and time.

Start by dragging the Date & Time Helpers helper to a workflow and select Get current timestamp from the operation dropdown.

date-time-helper-example1.1

We'll use the default timezone (UTC) but you could select any timezone from the dropdown combo based on your own requirements.

Step 2 - Get the day of the week

Next, we'll use the current date and time from step 1 to get the current day of the week.

Drag the Date & Time Helpers helper to the workflow and select Get day of week from the operation dropdown.

date-time-helper-example1.2.1

Now connect the Date & time input of the Get day of week operation to the output of step 1 by using the Connector Snake.

date-time-helper-example1.2.2

The Get day of week operation will take the current date and time from step 1 and work out the day of the week. Again, select the Timezone that you wish to work in. We are keeping everything in UTC for this example.

You should now have a workflow that looks like this with the Date & time populated with the json path of the step 1 output $.steps.date-time-helpers-1.result:

date-time-helper-example1.2.3

All we need to do now is run the worflow...

Step 3 - Run the workflow

Once the workflow has executed, you will be able to see the input and output of the Get day of week operation in the debug panel.

date-time-helper-example1.3

As you can see, the date/time and timezone were passed as inputs and the operation calculated the day of the week as Wednesday for the operation output.

Formatting the date

A date string or timestamp can be formatted into a particular style of writing using the Format date operation of the Date & Time Helpers connector. For instance, '2006-01-22' is represented by YYYY-MM-DD, while 'Sun, January 22nd 2006' is represented by ddd, MMMM Do YYYY.

Note that you can escape said characters by using either \ or []. For example, when using the timezone reference: Z:

date-time-helper-z

Date and Times can be represented in any way you want by combining the variables in the following table.

Token Output
Year YY 70 71 ... 29 30
YYYY 1970 1971 ... 2029 2030
Quarter Q 1 2 3 4
Qo 1st 2nd 3rd 4th
Month M 1 2 ... 11 12
Mo 1st 2nd ... 11th 12th
MM 01 02 ... 11 12
MMM Jan Feb ... Nov Dec
MMMM January February ... November December
Week of Year W 1 2 ... 52 53
Wo 1st 2nd ... 52nd 53rd
WW 01 02 ... 52 53
Day of Year DDD 1 2 ... 364 365
DDDo 1st 2nd ... 364th 365th
DDDD 001 002 ... 364 365
Day of Month D 1 2 ... 30 31
Do 1st 2nd ... 30th 31st
DD 01 02 ... 30 31
Day of Week d 0 1 ... 5 6
E 1 2 ... 6 7
do 0th 1st ... 5th 6th
dd Su Mo ... Fr Sa
ddd Sun Mon ... Fri Sat
dddd Sunday Monday ... Friday Saturday
AM/PM A AM PM
a am pm
Hour H 0 1 ... 22 23
HH 00 01 ... 22 23
h 1 2 ... 11 12
hh 01 02 ... 11 12
k 1 2 ... 23 24
kk 01 02 ... 23 24
Minute m 0 1 ... 58 59
mm 00 01 ... 58 59
Second s 0 1 ... 8 9
ss 00 01 ... 58 59
Fractional Second S 0 1 ... 8 9
SS 00 01 ... 98 99
SSS 000 0001 ... 998 999
SSSS ... SSSSSSSSS 000[0..] 001[0..] ... 998[0..] 999[0..]
Time Zone z or zz EST CST ... MST PST
Z -07:00 -06:00 ... +06:00 +07:00
ZZ -0700 -0600 ... +0600 +0700
Unix Timestamp X 1360013296
Unix Millisecond Timestamp x 1360013296123

All Operations

Latest version:

3.0

Compare times

Compare two time values, ignoring the dates/days.

Date is in the last...

Allows you to easily check if a given date has occurred in the last X number of seconds, minutes, hours, or days.

Format date

Subtract a number of duration types from a time value. Returns a UTC ISO string.

Get current timestamp

Returns the current date and time in a date string format (ISO 8601).

Get date property

Returns a number value from a date, such as the year, the day of the month, or the hour of the day.

Get day of week

Returns the day of the week for a given date. e.g. "Saturday" or "Tuesday"

Get days between

Get the number of days between two dates, rounded to the nearest day. If the second date is before the first date, the result will be negative.

Get duration

Given a total number of seconds, minutes, etc - return human readable text containing how long the duration was approximately, in the units of your choosing.

Get time between

Get the time between two dates, as hh:mm:ss. If the second date is before the first date, the result will be negative.

Get time from now

Returns a human readable date relative to the current time, such as "in 2 months", or "4 days ago".

Add to date

Add a number of duration types to a time value. Returns a UTC ISO string.

Compare dates

Compare two date/time values.

Is between dates?

Check to see whether a date falls within a date range

Is between times?

Check to see whether a time falls within a time range, ignoring the dates/days.

Is business hours?

Check to see if it's business hours or not, given a date in a given timezone.

Is weekend?

Check to see if it's the weekend or not, given a date in a given timezone.

Minus from date

Subtract a number of duration types from a time value. Returns a UTC ISO string.