calculateTimeDiff (time)
- 29 Jun 2023
-
DarkLight
-
PDF
calculateTimeDiff (time)
- Updated on 29 Jun 2023
-
DarkLight
-
PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Task Purpose
The calculateTimeDiff task calculates the difference between two timestamps and returns the result between them as a duration.
Potential Use Case
You could use the calculateTimeDiff task if you need to determine the remaining time (or elapsed time) between a recorded timestamp and today's date.
Properties
Input Variables
Incoming | Type | Description | Example |
---|---|---|---|
firstTime |
Object | Required. The base time from which the secondTime parameter is subtracted. This object must contain the following key-value pairs: • time - A string representation of the time. • formatString - The moment.js format the value of time must adhere to. |
{ "formatString": "YYYY-MM-DDTHH:mm:ss.SSSSSSZZ", "time": "2023-06-21T15:02:07.254000-1100" } |
secondTime |
Object | Required. The time that is subtracted from the firstTime parameter. This object must contain the following key-value pairs: • time - A string representation of the time. • formatString - The moment.js format the value of time must adhere to. |
{ "formatString": "YYYY-MM-DDTHH:mm:ss.SSSSSSZZ", "time": "2023-04-28T01:21:14.052000-1100" } |
Output Variables
Outgoing | Type | Description |
---|---|---|
timeDiff |
Object | The difference between the two time values expressed as a duration in multiple units. For example: "milliseconds": -2592000000 "seconds": -2592000 "minutes": -43200 "hours": -720 "days": -30 "months": -0.9856465225158627 "years": -0.08213721020965523 |
Example 1
In this IAP example:
- The
firstTime
property is provided by the output ofaddDuration
, another another task located elsewhere in the workflow. The reference variable provided by the other task isnewtime
. - The
secondTime
property is provided by the output of another task (referred to here asgetTime
) and the reference variable istime
. - For this example, let's say the incoming value of
secondTime
is less than the incoming value offirstTime
. Consequently, the outgoingtimeDiff
value will be a positive time reference such as: There are 'X' number of days between now and the future date.
Example 2
In this IAP example:
- The
firstTime
property is provided by the output ofgetTime
, another task located elsewhere in the workflow. The reference variable provided by the other task istime
. - The
secondTime
property is provided by the output of another task (referred to here asaddDuration
) and the reference variable isnewTime
. - For this example, let's say the incoming value of
secondTime
is greater than the incoming value offirstTime
. Consequently, the outgoingtimeDiff
value will be a negative time reference such as: The elapsed time since thefirstTime
deadline was surpassed bysecondTime
.
Was this article helpful?