# Need help with .toFormat('dd/MM/yyyy') function

**URL:** <https://community.n8n.io/t/need-help-with-toformat-dd-mm-yyyy-function/25707>\
**Category:** Questions\
**Tags:** expressions, luxon\
**Created:** [April 28, 2023, 12:10pm UTC](https://community.n8n.io/t/need-help-with-toformat-dd-mm-yyyy-function/25707 "2023-04-28T12:10:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fxholl](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/fxholl/32/18964_2.png) [@fxholl](https://community.n8n.io/u/fxholl)\
**Post date:** [April 28, 2023, 12:10pm UTC](https://community.n8n.io/t/need-help-with-toformat-dd-mm-yyyy-function/25707/1 "2023-04-28T12:10:24Z")

</div>

I am getting a date from a previous node and need to change the format:

{{ $node[“Extract consumer info, add registration link”].json[“timestamp”]}} returns 2023-04-28T08:56:42.244-03:00 but i need it to be 28/04/2023.

When I append .toFormat(‘dd/MM/yyyy’) it returns undefined:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/d/f/df68b49240cbae22a8acb21f31732ac5a6e48ae8.png)

What am I doing wrong?

## Information on your n8n setup

- **n8n version:** Version 0.222.3
- **Database (default: SQLite):** postgres
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):** main
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** docker
- **Operating system:**

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [April 28, 2023, 12:16pm UTC](https://community.n8n.io/t/need-help-with-toformat-dd-mm-yyyy-function/25707/2 "2023-04-28T12:16:44Z")

</div>

Hi @fxholl

You probably need to convert it to a date object first before you can set the format to what you want.  
So that would be something like .fromISO()

---

<div class="post-metadata">

**Author:** ![fxholl](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/fxholl/32/18964_2.png) [@fxholl](https://community.n8n.io/u/fxholl)\
**Post date:** [April 28, 2023, 3:49pm UTC](https://community.n8n.io/t/need-help-with-toformat-dd-mm-yyyy-function/25707/3 "2023-04-28T15:49:16Z")

</div>

> [@BramKn](#):
>
> convert it to a date

ah, i get it, the problem is that my date is a string and not a date object.

With help from ChatGPT, I converted the string to a date object using .toDate(), and then formated it using toLocaleDateString(‘pt-BR’).

The solution is :  
{{ $node[“Extract consumer info, add registration link”].json[“timestamp”].toDate().toLocaleDateString(‘pt-BR’) }}

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [May 5, 2023, 3:49pm UTC](https://community.n8n.io/t/need-help-with-toformat-dd-mm-yyyy-function/25707/4 "2023-05-05T15:49:29Z")

</div>

Closed on May 5, 2023, 3:49pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
