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