PadWorks
Posts: 2
Joined: Fri Sep 22, 2023 8:28 am

Highcharts feat. Timezones

Fri Sep 22, 2023 8:35 am

I feed my Series Chart with UTC values. The attribute UseUTC is false. Highcharts now correctly displays the individual client-side local time zone, as well as the daylight changeover. But now the problem is that for policy reasons, the user specifies to display the current time zone in the corresponding code for each timestamp (e.g. MESZ/MEZ when german language, CEST/CET when english language, etc.).

1. is there a possibility to add the time zone to the X-axis time label? (Codes, or external formatter function)

2. does Highcharts already provide a functionality for the correct time zone display within the Time class?

jakub.s
Posts: 984
Joined: Fri Dec 16, 2022 11:45 am

Re: Highcharts feat. Timezones

Fri Sep 22, 2023 9:27 am

Hi,

Welcome to our forum & thanks for the question!

You may find these links helpful:
- https://api.highcharts.com/highcharts/time
- https://api.highcharts.com/highcharts/time.moment (I believe that MomentJS library is what you're looking for)
- https://api.highcharts.com/highcharts/x ... .formatter (for formatting the labels, showing additional info)

1. Here's a simple demo: https://jsfiddle.net/BlackLabel/emfsnuv5/
2. You can use the time.timezone option to set a certain timezone.

Please let me know if that's what you were looking for. If not, please elaborate on this part: "user specifies to display the current time zone in the corresponding code for each timestamp" and I'll try to provide you with a more personalized answer.

Best regards!
Jakub
Highcharts Developer

PadWorks
Posts: 2
Joined: Fri Sep 22, 2023 8:28 am

Re: Highcharts feat. Timezones

Fri Sep 22, 2023 10:13 am

Thanks for the feedback.

1. So far solved, thank you. Had overlooked this in the API, sorry.

2. It's not about setting the timezone, but about getting it. Especially in the usual short-term format and depending on the browser language. (e.g. CEST in en-us, MESZ in de-ch or e.g. PET... ). I know javascript is PITA in this regard, so it would be awesome Highcharts already had this.

jakub.s
Posts: 984
Joined: Fri Dec 16, 2022 11:45 am

Re: Highcharts feat. Timezones

Mon Sep 25, 2023 8:54 am

Thanks!

1. Not a problem :) We're here to help.

2. So the problem you're having is getting to know the timezone of the browser's user? You can get the user's timezone like in this tutorial: https://www.tutorialspoint.com/how-to-d ... javascript
but then, you'd have to find a proper name of the timezone and pass it to Highcharts as an argument.

Articles that you may find helpful:
- https://stackoverflow.com/questions/404 ... imezone-js (if you decide to use moment)
- https://stackoverflow.com/questions/977 ... javascript
- https://bobbyhadz.com/blog/javascript-get-timezone-name
- https://api.highcharts.com/highcharts/t ... zoneOffset

If I understand your second point correctly, there's no built-in functionality like that in Highcharts.

Please let me know if that's what you were looking for.

Best regards!
Jakub
Highcharts Developer

Return to “Highcharts Usage”