To calculate the difference between two time fields in hours, minutes, or seconds, use the following formula:
getTimeDiff({{date_2}}, {{date_1}}, 's')
Where date_2 is the first time point (2nd time field) and date_1 is the second time point. Replace these with your own variables.
You can also change the units of time:
For hours: use ‘h’ instead of ‘s’
For minutes: use ‘m’ instead of ‘s’
For miliseconds: use ‘ms’ instead of ‘s’
Since time fields capture only hours and minutes, this difference is only less than 24 hs.
Note: This formula is valid only for two time fields or time values (same date).
Form Builder
In the Form Builder, we added two time fields, three text fields and a button.
Rule Builder
In the Rule Builder we added the following rule:
– Condition: When both time fields are present
– Actions: Evaluate our formula and display the result in the respective field
That’s it!