calculateTimeDiff (time)
  • 29 Jun 2023
  • Dark
    Light
  • PDF

calculateTimeDiff (time)

  • Dark
    Light
  • PDF

Article summary

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 of addDuration, another another task located elsewhere in the workflow. The reference variable provided by the other task is newtime.
  • The secondTime property is provided by the output of another task (referred to here as getTime) and the reference variable is time.
  • For this example, let's say the incoming value of secondTime is less than the incoming value of firstTime. Consequently, the outgoing timeDiff value will be a positive time reference such as: There are 'X' number of days between now and the future date.

calculateTimeDiff-ex01


Example 2

In this IAP example:

  • The firstTime property is provided by the output of getTime, another task located elsewhere in the workflow. The reference variable provided by the other task is time.
  • The secondTime property is provided by the output of another task (referred to here as addDuration) and the reference variable is newTime.
  • For this example, let's say the incoming value of secondTime is greater than the incoming value of firstTime. Consequently, the outgoing timeDiff value will be a negative time reference such as: The elapsed time since the firstTime deadline was surpassed by secondTime.

calculateTimeDiff-ex02


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.