Skip to content

Instantly share code, notes, and snippets.

@j0nes2k
Created November 5, 2013 09:26
Show Gist options
  • Save j0nes2k/7316272 to your computer and use it in GitHub Desktop.
Save j0nes2k/7316272 to your computer and use it in GitHub Desktop.
Highcharts currently does not support setting different timezones. One workaround was to send data in local time and tell Highcharts to treat these timestamps as UTC timezones. Another solution is to send the data in UTC timezone and use a different xAxis formatter to adjust the timezone difference. This is just a starting point for others facin…
xAxis: {
type: 'datetime',
labels: {
align: 'center',
y: 15,
formatter: function(){
var datetime = moment.utc(this.value);
var utcOffset = 0;
// utcOffset should be set globally to whatever timezone you want to show
if (self.options.utcOffset) {
utcOffset = self.options.utcOffset * 60;
}
if (utcOffset > 0) {
datetime = datetime.add('minutes', Math.abs(utcOffset));
}
else {
datetime = datetime.subtract('minutes', utcOffset);
}
return datetime.format('H:mm');
}
},
plotLines: []
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment