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