How do you convert a UTC string to local

I have a suspect I’m going to feel pretty stupid here.

Describe the problem/error/question

I have a UTC string that I want to convert to local date-time.
The string looks like this: “2025-02-26T23:30:00Z”

The JavaScript I wrote for the code node would not convert it. The conversion kept coming back as UTC.
After struggling for a couple hours, one question is this: Is the code executing from the EU at Zulu?
I finally deleted the code and simply did a Date.now and it came back as UTC timezone. So it appears to be the case (I’m in PST).
My workflow option settings are set to America/Los Angeles.

I did a direct conversion to PST for now but I may not always be in that timezone. I guess that the workflows are run from a fixed location(?) so how are others handling this?

I noticed that the Date-Time node is able to get a local date-time but JavaScript doesn’t seem to care.

What is the error message (if any)?

None

Please share your workflow

The issue is not a workflow problem I have JavaScript running in a code node.

(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:

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

You can use an expression:

2 Likes

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