Conversion and condition

Describe the problem/error/question

Question 1: How I can convert the timespace I receive from one node, to YYYY-MM-DDTHH:mm:ss.SSSZ format?
Example: from Error node, I got timestamp:1695883217175 i want it should be into YYYY-MM-DDTHH:mm:ss.SSSZ format for my API post request.

Question 2: How I can add the condition in the code node?
Example: from the set node, I am getting the value and next in code node I need to implement the coniditon like if A=$node[“set”].json[“propertyName”] then return this else return that.

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Gouravdev,

Question 1
n8n integrates the Luxion javascript library. To convert a UNIX timestamp in an ISO date you can write something like:
{{ DateTime.fromMillis($input.item.json.timestamp).toISO(); }}

A couple of resources:

Question 2
It depends on the context and on what you want to achieve. Can you share more details and an example of the Code Node?

Best

For question1,

error node, is giving this response.

Now, how I can handle this with {{ DateTime.fromMillis($input.item.json.timestamp).toISO(); }}

Hi @Gouravdev
in the next node you can switch the parameter where you want to use that date to Expression and then input:
{{ DateTime.fromMillis($json.execution.error.timestamp).toISO() }}

See an example here:

Let me know if that helps

hi @Gouravdev

for the 1st question, you can also use more simple syntax:
{{ new Date($json.execution.error.timestamp).toISOString() }}