1. Click on Add an action under the If yes branch of your condition
2. Search for ‘add to time’ and select the action from the result list.
3. To edit the action, click into Base time and switch to the Expression tab in the context dialog:
4. Enter the expression* into the function box (fx) and save your webhook:
NB: This example assumes that the date/time field in your survey is called 'survey_datetime'. If it's different in your survey, you need to modify the expression accordingly.
* I am aware that a similar expression exists in this blog article, but all the date formatting strings I've tried gave me an error in Flow. I believe Flow was updated since that article and no longer accepts the formatting string as part of the expression. When leaving the formatting string out, the expression was accepted and works just fine.
So, what does the above snippet do?
The addseconds() function adds the seconds specified to a base time. The base time for Unix is 1st January 1970, hence the '1970-1-1' part as base. Then in the second parameter we call the dynamic value from the ‘survey_datetime’ field – but as this is in milliseconds, we need to divide this by 1000 as the addseconds() function needs a value in seconds. That’s why we added the div() function, which provides this division for us.
You can add a static hour/day/month/etc. value to this calculation specifying the Interval and Time unit in the step. (For example if your device's clock is misconfigured.) We don't need to add anything in our case, so we just set it to '0 Hour'.
Convert time zone and format string
As discussed above, your survey's date & time is submitted in UNIX format (also known as UNIX Epoch, UNIX timestamp or POSIX time) which starts at midnight (UTC) on 1st January 1970. If your local time zone is different from UTC, you may want to convert the calculated time into your correct time zone.
The below steps assume you have completed the time calculation step in the previous section.
1. Click on Add an action under the If yes branch of your condition.2. Search for ‘convert time zone’ and select the action from the result list to add it to your flow.
3. Click into Base time, then in the Dynamic content tab of the context dialog select Calculated time – this is the function we just created in the top half of this article. 4. Set up the Source time zone (it must be UTC) and your Destination time zone, then choose a Format string you want to use.
In Part 3 we will discuss how to include the calculated/converted time and other dynamic content in the notification email and where to find additional settings for your webhook.