Table of Contents

Get a timestamp according to a defined TimeZone

Pau Sanchez Updated by Pau Sanchez

We have built a Brick with a flow ready to be used, this will retrieve a timestamp from the timezone you select, and different formats you can use. For this we will use the great API http://worldtimeapi.org/

This Brick contains Webhook and Formulas block, check if your subscription plan can use them
Timezone and API request set up
  1. Import the brick "TimeStamp v1":

  1. Connect it to your flow:
  1. Enter the brick:

  1. Select your time zone and use it in "Set variable":

You can check here for a list of time zones to make sure you're using the correct formatting

  1. Select the Webhook and scroll down to the Save Responses as Variables:

  1. Press "CREATE", to create a new variable for @response
  2. Select array format
  3. Press "CREATE"
  4. Now should be like this:
Timestamp formats and variables

The brick, once the set variable with the timezone and the webhook are set up correctly you can choose the format that fits your needs.

By default the brick will offer you the following formats:

So in the testing message block:

And will be displayed like created in this formats:

Here is the list of variables with the formats:

@unix_timestamp => 1616133235

@datetime_raw => 2021-03-19T06:53:55.619785+01:00

@date => 2021-03-19

@time => 06:53:55

@datetime_timestamp => 06:53:55 2021-03-19

Note, you can delete the sample message block, is only needed for testing purposes

Day of the Week

In case you want to get also or only the day of the week (Monday, Tuesday...), the great World Time API offers more information that we can use. As you can see here in the response of their API they have a field for the "day_of_week"

As we can see "day_of_week" is 3, that means is Wednesday.

Once we make sure the Webhook and Timezone are set properly (steps 1 to 8) then:

  1. Add a Formula block

  1. Add the following formula to extract the number that represents the day of the week

GetValue(@response,"day_of_week")

  1. We will save the number in a variable called @day_of_week, type number

  1. Set to "Block outputs" to Custom

  1. We will add the numbers of the days
  2. Then we add a set variable for each one of the possible outputs with the variable @day where we want to store the value, and with the name of the day of the week

And now in the variable @day, you will have the day of the week

How did we do?

Age Calculator Brick Workaround

Simple cart v0.2

Contact