score:11

Accepted answer

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.

score:0

use timezone by getfunction Example: Using getTimezoneOffset

var x = new Date();
var currentTimeZoneOffsetInHours = x.getTimezoneOffset() / 60;

score:1

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;
          }
      }
  });

});

score:4

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/

score:6

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.

score:7

Highcharts now supports timezones in 3.0.8

You can now set the timezoneOffset global property: http://api.highcharts.com/highcharts#global.timezoneOffset


Related Query

More Query from same tag