toLocaleString inconsistency between Set and Code nodes

Describe the problem/error/question

I’m facing inconsistent behavior from Luxon’s toLocaleString function between Set and Code nodes.

See the following workflow:

In this forum’s preview, the return values for with_locale and without_locale on the Set node are 4/17/2023 and 11:15:12 respectively.
In my n8n instance, the return values for the Set node are 11:15:12 and undefined, respectively, for with_locale and without_locale. The results are completely different.

As for the Code node, I get the same results as this Set node preview: 4/17/2023 and 11:15:12

What could be the cause of different behavior between Set and Code nodes regarding Luxon?

Also, I think this could be related to the following thread: Trouble with .toLocaleString in latest version of Docker

Information on your n8n setup

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

Hey @miguel-mconf, I am sorry you’re having trouble. There are a bunch of differences here, the forum instance would for example use a more recent version of n8n than you have currently in use.

Could you confirm if you are also seeing different results when actually executing the workflow and which time zone environment variables (TZ, GENERIC_TIMEZONE) you have set on your own machine?

On a more general note, because n8n’s expression behaviour can differ depending on the locale settings of both the browser (when using the preview functionality) and your instance, I’d suggest you simply hard code the desired format.

Something like .setZone('Europe/Amsterdam').toFormat('HH:mm') should produce identical results, no matter of the context you are running your workflow in:

1 Like

Hi, sorry for the late reply.

I can confirm that by setting the TZ environment variable, and updating n8n to 0.226.0, the reported issue is gone, though I’m not sure which one fixed it.

Thank you for your attention.


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