I’m trying to send a timestamp to a Google Sheet. Therefore, I use the expression $now.format(“HH:mm”).toString(). In n8n, the timestamp looks correct (see screenshot).
However, in Google Sheets, the string value is 2 hours off (so it does not consider the timezone).
Any thought on how to solve this?
n8n
June 17, 2024, 10:59am
2
It looks like your topic is missing some important information. Could you provide the following if applicable.
n8n version:
Database (default: SQLite):
n8n EXECUTIONS_PROCESS setting (default: own, main):
Running n8n via (Docker, npm, n8n cloud, desktop app):
Operating system:
aya
June 17, 2024, 12:17pm
3
Hi @strongbow ,
To format a DateTime object based on the user’s locale settings:
{{$now.format("HH:mm").toLocaleString()}}
If you want to specify a timezone:
{{$now.setZone('America/New_York').format("HH:mm")}}
You can find more information on how to n8n handle date and time in the docs here: Handling dates | n8n Docs
Hope that helps!
Hey @aya , thanks for your response!
toLocaleString()
didn’t work
setZone('Berlin/Europe')
did work - although locale and timezone I set were the same.
aya
June 17, 2024, 2:42pm
5
Could you tell me what the output looks like when you try toLocaleString()
@strongbow Check this thread on using time and dates in n8n
Manipulating Time and dates in n8n
Time and dates are some of the key data we use on an almost daily basis. How about when iut comes to n8n, how do we format this data for easy use.
For a while I have been working with n8n and dates and time has been one of the interesting parts on it. I will show you a few tricks you can use in n8n to do quite a few things and manipulations on time and dates using simple code snippets as listed below.
Filter dates that are not weekends
Minus time and dates f…
2 Likes
system
Closed
June 24, 2024, 4:06pm
8
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.