I'm trying to format a date but it's not working

Hey,

I’m trying to format the following date: {{ $(‘Webhook’).item.json.body.createdAt }} to make it return the date in MM/DD/YYYY.

I asked Grok and it suggested trying this out: {{ DateTime.fromISO($(‘Webhook’).item.json.body.createdAt).toFormat(‘MM/dd/yyyy’) }} but it’s still not returning the date in the right format.

How can i fix this?

Thanks!

You can use date functions provided by n8n.

.toDateTime() to convert a string into a date object.
.format('MM/dd/yyyy') to format the data object.

{{ $(‘Webhook’).item.json.body.createdAt.toDateTime().format('MM/dd/yyyy') }}

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