Date/Time Node
The Date/Time Node allows you to manipulate date and time data on the current payload.
Node Properties
In order to use the Date/Time Node, you’ll need to provide an optional source date, specify an operation to perform on that date, and then determine where on the payload you’d like to store the result.
Source Date
The Source Date section of the Date/Time Node includes fields that allow you to retrieve the data from the current payload for the date or time you’d like to manipulate.
- Source Path: You may optionally include a payload path that points to a valid date object on the current payload. If you leave this field empty, the source time will default to the current time.
- Source Format Template - If you know the format of the source date, you may optionally provide that here as well (unless the date is in standard format -
YYYY-MM-DDTHH:mm:ssZ
- in which case this step is not necessary). This may also be a string template that references the format you are specifying. If you leave “Source Path” empty, you do not need to fill out this field.
Operation
The operation section provides varying fields that depend on the operation you choose from the dropdown. The available operations you are able to perform are outlined in the Operations section below.
Result Path
The Result Path section defines where you’d like to store the result of the operation.
- Output Timezone: This field will convert the result of the above operation into the selected timezone. The default selection is based on the timezone set in your browser settings. Note that if the source time doesn’t specify a timezone or GMT offset, or if the Source Path field was left blank, it will be considered GMT (UTC) time before evaluating this field.
- Result Path: You must include a payload path on which to store your result.
Operations
Depending on what operation you choose to perform, additional configuration may be required.
Add Time
Adds time to the source date.
- Amount To Add Template: The numerical value to add to the source date object, or a valid string template that references it.
- Unit [1]: The unit of time to describe the value passed above.
Days in Month
Gets the number of days in the month of the source date.
Diff
Gets the difference in milliseconds between the source date and the date provided.
- Path of Data to Compare: An optional payload path that points to a valid date object on the current payload. If you leave this field empty, it will default to the current time.
- Source Format Template: The format of the date object you are comparing, or a string template that references it. If you leave “Path of Data to Compare” empty, you do not need to fill out this field.
Format
Formats the source date to the provided format string. If no format is provided, the source date will be returned in standard format (YYYY-MM-DDTHH:mm:ssZ).
- Result Format Template: The format to which you’d like to convert your date, or a string template that references it.
Get Date Part
Gets a certain part of the source date. You may get year, quarter, month, week, day, hour, minutes, seconds, or milliseconds.
- Part to Retrieve: The unit of time you’d like to retrieve.
Set Date Part
Sets a certain part of the source date. You may set year, quarter, month, week, day, hour, minutes, seconds, or milliseconds.
- New Value Template: The numerical value of the new date part, or a valid string template that references it.
- Part to Set: The unit of time you’d like to set.
Subtract Time
Subtracts time from the source date.
- Amount To Subtract Template: The numerical value to subtract from the source date object, or a valid string template that references the value you’d like to subtract.
- Unit [1]: The unit of time to describe the value passed above.
Start Of Time
Sets the source date to the beginning of a unit of time.
- Unit [1]: The unit of time to set the source date to the beginning of.
To Array
Returns an array of date parts.
To Object
Returns an object containing the year, month, day, hour, minute, seconds, and milliseconds of the source date.
Unix Timestamp Milliseconds
Returns the Unix timestamp of the source date in milliseconds.
Unix Timestamp Seconds
Returns the Unix timestamp of the source date in seconds.
Node Example
In the example configuration from the screenshots above, the workflow takes the time from when a virtual button is pressed and adds one year to it. When the result of this operation is placed on the path working.oneYearLater
, it will result in the following data.
{
"working": {
"oneYearLater": "2029-08-16T20:30:38.466Z"
}
...
}
Node Errors
The Date/Time Node will place an error on the payload if it receives an invalid reference to a date. For example, if we change the data in “Source Path” to something invalid, say, “invalidDate”, it will return the following error on the working.oneYearLater
path that we specified:
{
"working": {
"oneYearLater": {
"error": {
"message": "Invalid date: invalidDate",
"type": "InvalidType"
}
}
}
...
}
Footnotes
[1]: The "Month" unit is zero-indexed, meaning that January will return with a value of 0, February with a value of 1, and so on. This behavior is derived from Javascript.
Was this page helpful?
Still looking for help? You can also search the WEGnology Forums or submit your question there.