I am one week into learning node-red, and I have got some problems with handling different timezones.
I tried hard to find a solution for my problem online, but I coudn't.
I am running node-red on a raspberry pi near Singapore (UTC+08:00). I am living in central europe (UCT+01:00). Time settings on the raspberry pi are correct.
When I access the node-red editor or the dashboard via my browser, it seems that node-red is mixing up the two different timezones.
For example, the timestamp on the debug message in the node-red editor is always browser time although it recognizes the local time from the server.
Also, when I use the chart node, the shown period of time on the x-axis is always the time from my timezone to the time from the server. It is ignores the setting in the chart properties.
My question, is it possible to force node-red to globally use server time?
Those are both the same time, so not necessarily incorrect. How are you setting msg.payload?
What setting in the chart properties?
Also how are you adding data to the chart?
[Edit] I see what you mean about the time range. So how are you adding data to the chart, and does it show at the correct time? It should be in browser time with the current time at the RHS if you are sending values one at a time to the chart and not specifying a timestamp with the data.
You are right - the time is not incorrect. For setting the payload I periodically read a sensor value from the raspberry pi. Then I format the timestamp with date/time formatter node (to get Singapore time) and forward the message to the chart. This way, the sensor values are displayed at the correct local time, but as I mentioned the time range is way bigger than I want it to be. I want the chart to display ~ 1 minute of data. I adjusted the chart property to just show me last 1 minute, but it always ends up showing me last 7 hours of data.
When I do not use the date/time formatter node, the displayed time range is correct, but the time on the x-axis is browser time. Also the sensor values are beeing displayed in browser time. Technically it is not wrong, but it is confusing and I want values to be displayed in local time.
So without the date/time formatter node all is as it should be, except that you want the browser to show times in Singapore time, not in the timezone of the PC. It is the browser that needs to be adjusted, not the timestamps in the chart.
How to do that depends on the browser. Your browser may have the option of changing the timezone, or there may be a plugin to do that.
Alternatively perhaps set the timezone of the PC to Singapore.
A further alternative would be to configure the Pi to use your local timezone rather than singapore time.
Yes this is correct. I already changed the timezone of my browser to Singapore time, and it worked out fine. But the problem is, I also deployed a node-red dashboard on a Pi in my local timezone. And if I change the timezone of the browser, than this Pi is showing data in Singapore time, but is located in Europe. So this is not a proper solution for me.
For me personally the best way to solve this would be to somehow force node-red to just use server time and simply ignore browser time. Is this somehow possible?
It isn't node red that is using browser time, it is the browser that is using the browser time. For the chart, node red just tells the browser to display a date/time and the browser displays it the way it wants to. I doubt if there is any way for a server to force the browser to use a particular timezone.
Have you checked for browser plugins as I suggested. Perhaps there is a plugin that allows timezone dependent to the url. If not then one that allows you easily to switch between timezones.