ericplan
Posts: 91
Joined: Thu Apr 11, 2019 8:24 pm

Setting Timezone and convert from UTC to local time

The charts from my solar plant logging are stored in a MySQL database. Until now the data was stored on the database server in local time, but because I had some troubles with Daylight Saving Time, I store the data in UTC from now on.

The workflow is as follows:
MySQL server > PHP framework for generating the charts > Highcharts.

The timezone adjustment could take place on more locations:
-via a MySQL query
-via PHP
-via Javascript
or maybe via Highcharts?

I'm looking for the simplest option. Is there an easy way for Highcharts charts to receive data in UTC and display it in Local time?
Regards,

Eric from Amsterdam
jakub.s
Posts: 1228
Joined: Fri Dec 16, 2022 11:45 am

Re: Setting Timezone and convert from UTC to local time

Hi,

Thanks for the question!

time.getTimezoneOffset property allows you to set a certain timezone for all the UTC dates you include in your charts.
Take a look at this link: https://api.highcharts.com/highcharts/t ... zoneOffset and this demo: https://jsfiddle.net/gh/get/library/pur ... oneoffset/

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

Kind regards!
Jakub
Highcharts Developer
ericplan
Posts: 91
Joined: Thu Apr 11, 2019 8:24 pm

Re: Setting Timezone and convert from UTC to local time

This is perfect! I spent some time in PHP last weekend to repair some code, but this is such a clean solution. Thanks for your help, thanks to the forum. I only had to update the moment library, but that's not very hard :)

Regards,
Regards,

Eric from Amsterdam

Return to “Highcharts Usage”