Converting dates in Make(formerly Integromat)
Learn how to format dates in Make (formerly Integromat)
Handling dates in Make(formerly Integromat)
Knowledge Level: Advanced
When working with webhooks, you will come across scenarios where you are using dates. Dates are handled in two ways via The Bot Platform:
- The webhook contains a unix timestamp which represents the time at which the webhook was inititated
- bot user inputs date which is captured through an attribute in the platform and passed on through a webhook.
In the below steps, we will demonstrate a few examples which you can use to convert dates to various different formats using Make(formerly Integromat).
Converting unix timestamp to human readable format
Let's see this example below. We have a webhook with the 'timestamp' in Unix time format:
Note: A unix time stamp is a way to track the time as a running total of seconds, this count starts at the Unix Epoch on January 1st, 1970 at UTC.
![timestamp webhook.png 442](https://files.readme.io/a561761-timestamp_webhook.png)
To convert this to a date in human readable format, we will use one of Make(formerly Integromat) date operator.
You will find these operators when adding webhook data to another data point such as a Google Sheet.
For conversion, the formula will look like this:
![integromat unix formatter.png 776](https://files.readme.io/e1713bd-integromat_unix_formatter.png)
Using the 'fomratDate' operator, we parse the 'timestamp' from our webhook and define an output format.
In this case, we used the format 'DD/MM/YYY' as output.
When the scenario runs successfully, the output in your Google Sheet will show as below:
![output data sheet.png 242](https://files.readme.io/92fa159-output_data_sheet.png)
Add or subtract days in Make(formerly Integromat)
Similar to the above scenario, we can perform calculations on a date entered by the bot user.
For example, we can add two days to a date entered by the bot user and submit the output to a Google sheet.
See example below:
![format date add days.png 414](https://files.readme.io/3f437d7-format_date_add_days.png)
In the above example, we first formatted the date to our preferred format i.e DD/MM/YYY, after formatting we used the operator 'addDays' to add two additional days to the actual date.
Our output in Google Sheet can be seen below:
![output sheet.png 318](https://files.readme.io/79590c1-output_sheet.png)
Updated 4 months ago