Uncorrect time while calculating date/time

Hi Everyone!

When I try to calculate a date, the result time looks completely weird. The operation i’m tryng to make is substracting 10 minutes to current date/time.

For this, I used a “Date&Time” node which date value is “{{Date()}}” (displays current date&time) and that should substract 10 minutes.
The problem’s that current time looks correct, but the result after substraction (that should be just 10 minutes earlier) is 1h earlier than the time it should be.
For example if I lanch the node at 12:00, the result should be 11:50. Currently it’s 10:50 and I don’t know why one more hour is substracted.

How would you manage that?

Thank you in advance!

Hi @Anthony73370, this sounds like your time zone configuration might be off. There are two relevant environment variables at play here, one is the GENERIC_TIMEZONE (explained here) which is used by the Cron node for getting the start time right.

The other one is TZ (explained here) which would be used by your system and also by code executed in n8n. Is there possibly a mismatch between the two?

You could read them by running a workflow like below:

Hi @MutedJam !

Thanks for your help, but I still cannot make it work…

I do not find an input to setup a specific TZ. The reason why I’m stunned is that the reference time is correct, but when you run the node to add or substract even 1minute, the result time keeps being 2 hours late.

I tried to change my EC2 instance’s TZ but doesn’t seems to make a change

The reason why I’m stunned is that the reference time is correct, but when you run the node to add or substract even 1minute, the result time keeps being 2 hours late.

Is the result actually wrong or is simply the wrong offset being used? For example 2022-07-13T10:53:54.872+02:00 and 2022-07-13T08:53:54.872Z would both specify the same moment in time.

If it’s just the offset that is causing irritation here, you might want to use a simple Luxon expression instead of the Date & Time node. This approach would allow you to specify the time zone to avoid any ambiguities that might occur on your system. This could also be done through an additional Date & Time node. Here is an example for both: