[BUG] diffToNow

the diffToNow function is not respecting the time zone and I believe that other functions are not respecting it either, because this is not the first time I have had this problem.

Share the output returned by the last node

Information on your n8n setup

  • **n8n version:1.67.0
  • **Database (default: SQLite):postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):docker
  • **Operating system:ubunto 20.04

@Jon
@ihortom

Have you seen this error in the time zone?

Hey @Ruan17 , I do not see discrepancies in your presented output. One of us is reading it wrong.

You are in the timezone (workflow set up in the timezone) with 3 hours different from UTC (-03:00).

The function diffToNow() is for local time (aka in timezone -03:00).

If you disregard the timezone, the difference in time was 57 mins. If you take into consideration the timezone difference it comes to 237 mins. If you add 3 hours it becomes 57 mins again.

All adds up. What am I missing?

I improved the explanation

@ihortom I sent new information

Hey @Ruan17 , thanks for clarification. I believe that is how the Luxon function works - before subtracting it bring both times to the same time zone.

What you could do is to use minus() function instead as in

{{ DateTime.fromISO("2024-11-17T09:00:00.000Z")
.minus({hours: 3}).diffToNow('minute') }}
//         UTC-3

Excellent, I believe I will be able to get around my first problem, now I have this problem

When I run it, it seems like the times are correct, but the node saves the values ​​with a +3 time zone difference

Note that my time zone is UTC-3, so the result when saved in the node is as if the time zone were UTC 0

correct result in green, with all times according to the UTC -3 time zone

the arrow on the right side is correct with the times, but when saved in the node on the right side it is as if the UTC is set to 0 and saves all the results we are seeing (the one on the left side)

how to solve this bug?

workflow

You can adjust the timezone in the flow settings Maybe that helps?

1 Like

It’s already adjusted, in the workflow, in the n8n installation, on the server, I think it’s already a bug, what do you think @ihortom ?

@Jon Have you seen this bug?

Have you had any updates about this BUG?:smiling_face_with_tear: