As far as I understand the default for Highcharts is to UTC. I have tried to do as suggested by the answer in this post Highcharts graph X-axis label for different date ranges. If I understand correctly this should set the timezone to be that of the browser.
I've tested this on jsFiddle and toggling the useUTC
option seems to have no effect.
http://jsfiddle.net/looneyp/me3ry/
Question: What am I doing wrong above and how do you set the time zone correctly?
Highcharts have moved this option in more recent versions.
One thing to keep in mind is that your shift seems to be the inverse or negative of where your local time from UTC, so if you're in UTC+2 for example, then your timezoneOffset
is going to be -2 * 60
, which is not entirely intuitive:
Highcharts.setOptions({
time: {
timezoneOffset: -2 * 60
}
});
API documentation: https://api.highcharts.com/highcharts/time.getTimezoneOffset
Here is an example of it: http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/time/timezoneoffset/
Add this code to the document.ready and you should get the highcharts in your local timezone if you're feeding it UTC time
$(document).ready(function () {
Highcharts.setOptions({
global: {
/**
* Use moment-timezone.js to return the timezone offset for individual
* timestamps, used in the X axis labels and the tooltip header.
*/
getTimezoneOffset: function (timestamp) {
d = new Date();
timezoneOffset = d.getTimezoneOffset()
return timezoneOffset;
}
}
});
});
It's one of those days
I'm in the UK so UTC true or false gives the same results since I am in GMT. My discrepancy between my expected displayed time was due to a parsing issue in PHP to unixTime.
Highcharts now supports timezones in 3.0.8
You can now set the timezoneOffset global property: http://api.highcharts.com/highcharts#global.timezoneOffset
Nothing you are doing seems to be wrong. This jsFiddle shows a shift in the x-axis when UTC is disabled in the global Highcharts options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With