Over the past week I have been playing with a self-hosted instance of n8n – a Zapier-like automation platform. I quickly ran into an issue, that took a while to debug and I’d like to share my solution here.
I run a pretty standard docker-compose setup.
services:
n8n:
image: n8nio/n8n:latest
ports:
- "5678:5678"
environment:
- GENERIC_TIMEZONE="Europe/Berlin"
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=n8n-db
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=n8n
volumes:
- "./n8n-node/:/home/node/"
depends_on:
- n8n-db
- warehouse-db
restart: unless-stopped
[…]
I live in Timezone Europe/Berlin, so I added the timezone ENV-variable.
The container starts fine and I can create workflows.
Now the weird thing was that date/time processing was broken.
Whenever I would create date/time converting nodes or expressions like {{ $now }}
or {{ new Datetime("2024-05-12") }}
or {{ DateTime.fromISO("2022-12-24") }}
it would always bring up an error message Result: [invalid DateTime]
N8n is using Luxon library for date/time processing and I didn’t get why all provided examples where failing. Several searches and debugging did not bring me closer to a solution. I made sure I was using the latest version of n8n.
When I came across this question, where somebody had a similar problem a year ago. This pointed towards the timezone.
I had my time zone configured as:
…
- GENERIC_TIMEZONE="Europe/Berlin"
–
Which turns out is just wrong… writing it this way has the quotation marks as part of the string thus the timezone n8n was parsing wasn’t ‘Europe/Berlin’. but ‘”Europe/Berlin”‘.
Removing this faulty line, the date/time processing with Luxon worked like a charme!
…
- GENERIC_TIMEZONE=Europe/Berlin
–
So getting Invalid DateTime
means, luxon fails to parse the timezone and can’t return a valid result. You can try this also with unknown time zones like “Europe/Berlin123” – same error.
So fix your time zone config and the error will vanish!