fxholl
1
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:
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:
BramKn
2
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()
2 Likes
fxholl
3
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’) }}
2 Likes
system
Closed
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.