Make Highchart use a specific target time zone

I use highchart to display data on the x-axis. The data refers to a specific location on the globe, so I need HightChart to display the time of that location. This is not UTC or the time zone of the local browser.

I already saw the UTC setting to use the local UTC or browser time:

Highcharts.setOptions({ global: { useUTC: true } }); 

And I'm already thinking about applying a delay according to my target time zone in label formatting. but a little more complicated: how to manually control the summer / winter time switch in any country, etc.

Maybe if there is a way to set the timezone in the javascript date object to use getLocalString() with a specific getLocalString() /

Any idea on how to do this?

+4
source share
3 answers

A possible solution is to use UTC in Highcharts, then if you know which time zone you want to display, you already know the offset. Then just in all formatters (xAxis, tooltip, etc.) add an offset to display the correct date.

+1
source

If this is not the time zone of the local browserโ€™s time zone, then simply put the timestamp as part of your series, either as a second array for the x-axis label, or pointStart in combination with the pointInterval series parameters if your data is regularly posted.

In any case, it seems to you that you need to do preprocessing on the server side to get the correct time zone.

+1
source

I had the same problem and I decided to set useUTC: false and then the server sent timestamps for the required time zone. In my case, the server sends "Eastern time" data, and all the graphs show the eastern time on the x axis, however, the client is not in eastern time.

0
source

Source: https://habr.com/ru/post/1486566/


All Articles