# Invalid date

**URL:** <https://community.n8n.io/t/invalid-date/44046>\
**Category:** Questions\
**Created:** [April 10, 2024, 2:41pm UTC](https://community.n8n.io/t/invalid-date/44046 "2024-04-10T14:41:08Z")\
**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 10, 2024, 2:41pm UTC](https://community.n8n.io/t/invalid-date/44046/1 "2024-04-10T14:41:08Z")

</div>

## Describe the problem/error/question

I am using the following expression to convert a GMT date and time to Brasil timezone:

{{ DateTime.fromFormat($json[‘Submitted at’], ‘yyyy-MM-dd HH:mm:ss’, { zone: ‘utc’ }).setZone(‘America/Sao\_Paulo’).toFormat(‘yyyy-MM-dd HH:mm:ss’)}}

It usually works, like in this case:

 ![Screenshot 2024-04-10 11.35.43](https://europe1.discourse-cdn.com/n8n/original/3X/7/e/7e2e78be4d48a7f1b6369e9276ad48aaf6e034ec.jpeg)

However it sometimes returns an error:

 ![Screenshot 2024-04-10 11.37.55](https://europe1.discourse-cdn.com/n8n/original/3X/b/e/beb2364d3b5fbc8b63cc3ddf6773462dfd55021a.jpeg)

Can someone help me understand what I am doing wrong?

## Please share your workflow

## Share the output returned by the last node

## Information on your n8n setup

- **n8n version:** v1.31.2
- **Database (default: SQLite):** sqlite
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):** main
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** docker
- \*\*Operating system:\*\*ubuntu

---

<div class="post-metadata">

**Author:** ![liam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/liam/32/34968_2.png) [@liam](https://community.n8n.io/u/liam)\
**Post date:** [April 10, 2024, 2:51pm UTC](https://community.n8n.io/t/invalid-date/44046/2 "2024-04-10T14:51:17Z")

</div>

Oi! Tudo bem?

The reason is your time format is actually `H:mm:ss` not `HH:mm:ss`. You can tell because the hour in your screenshot is 2 instead of 02. It works sometimes because any time after 10:00 in the `H` format would be able to be parsed by the `HH` format

change your expression to this and it will work:

```auto
{{ DateTime.fromFormat($json['Submitted at'], 'yyyy-MM-dd H:mm:ss', { zone: 'utc' }).setZone('America/Sao_Paulo').toFormat('yyyy-MM-dd HH:mm:ss')}}

```

All i changed was the HH to H in the `.fromFormat` method

---

<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 10, 2024, 5:56pm UTC](https://community.n8n.io/t/invalid-date/44046/3 "2024-04-10T17:56:25Z")

</div>

awesome!

I will test and report back

---

<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:** [April 21, 2024, 1:51pm UTC](https://community.n8n.io/t/invalid-date/44046/4 "2024-04-21T13:51:21Z")

</div>

Closed on April 21, 2024, 1:51pm UTC

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