# Handling Dates

At Hablla, the **date handling** is essential for setting up automations, defining deadlines, and creating smart rules within the flow. You can set dates automatically using expressions inside fields, without needing to code.

### 🌍 Adjusting the Time Zone

The times used in automations follow the **UTC (Coordinated Universal Time) standard**. However, depending on where you are, it may be necessary to adjust that time.

✅ **Example for Brazil:**\
The **Brasília time zone** is UTC **-3**. To adjust any date to the correct time, simply subtract **3 hours** from the generated date.

***

### 🔹 How to Set Dates Dynamically?

In Hablla, we use **date expressions** inside **{{ }}** to calculate and set values automatically.

#### ✅ **Set Current Date** (with time zone adjustment)

If you want to set a field with the **date and time of the automation moment**, adjusting for Brasília (UTC -3), use:

```
{{new Date(Date.now() - 3 * 60 * 60 * 1000)}}  
```

📌 **Example:** If the execution occurs on **March 4, 2025 at 14:00 UTC**, the adjustment will show **"Tue Mar 04 2025 11:00:00 GMT-3"**.

***

#### ⏳ **Adding Time to the Current Date**

If you need to add minutes, hours, or days to the current date, just add the corresponding value to `Date.now()` and subtract the 3 hours for the time zone.

**➕ Add Minutes**

Each minute equals **60,000 milliseconds**. To add 20 minutes and adjust to UTC -3, we use:

```
{{new Date(Date.now() + 20 * 60 * 1000 - 3 * 60 * 60 * 1000)}}  
```

📌 **Usage Example:** Set the **Start Date** of a task to 20 minutes in the future.

***

**⏳ Add Hours**

Each hour equals **3,600,000 milliseconds**. To add **3 hours**, already considering the time zone, we use:

```
{{new Date(Date.now() + 3 * 60 * 60 * 1000 - 3 * 60 * 60 * 1000)}}  
```

📌 **Usage Example:** Set the **End Date** for 3 hours after the task start.

***

**📅 Add Days**

Each day has **86,400,000 milliseconds**. To add **2 days** and keep the time zone adjustment, we use:

```
{{new Date(Date.now() + 2 * 24 * 60 * 60 * 1000 - 3 * 60 * 60 * 1000)}}  
```

📌 **Usage Example:** Set a due date for 2 days after the task is created.

***

#### ⏰ **Set an Interval between Dates**

<figure><img src="/files/5f8b098a269f6d2f010933f91e1a1c31445d943f" alt=""><figcaption><p>Configuration of a Hablla component to Create Task</p></figcaption></figure>

If you need to configure **Start Date and End Date**, you can use different expressions for each field.

🔹 **Start Date:** 20 minutes from the current moment (UTC -3):

```
{{new Date(Date.now() + 20 * 60 * 1000 - 3 * 60 * 60 * 1000)}}  
```

🔹 **End Date:** 40 minutes after task creation (UTC -3):

```
{{new Date(Date.now() + 40 * 60 * 1000 - 3 * 60 * 60 * 1000)}}  
```

📌 **Usage Example:** Create a task that starts in 20 minutes and ends in 40 minutes.

***

#### 🕑 **Subtract Time from the Current Date**

If you need to set a time **before the current moment**, just **subtract** values.

🔹 **Example: Set a time 1 hour ago (UTC -3):**

```
{{new Date(Date.now() - 1 * 60 * 60 * 1000 - 3 * 60 * 60 * 1000)}}  
```

📌 **Usage:** Create an event with a past date.

***

### 🎯 **Final Tips**

✅ **Always adjust the time zone** according to your location. Brazil uses UTC **-3**, but if it is another location, adjust as necessary.\
✅ **Multiply the values correctly** for minutes, hours and days.\
✅ **The generated dates follow the UTC format**, but can be converted by the system automatically.\
✅ **Testing before applying** helps avoid configuration errors.

🚀 **With these techniques, you can automate tasks and deadlines correctly, always respecting the local time!**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hablla.com/hablla-docs-en/automation-flows/handling-dates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
