I want to display the time zone on the date/time tooltip.
The xDateFormat
option does not have an option to display timezone.
https://jsfiddle.net/u7z28fbp/1/
For eg:
Currently the date tooltip shows: Friday, April 5, 2019
I want it to show: Friday, April 5, 2019 UTC +00:00
Try this:
https://jsfiddle.net/q8s2jdgp/1/
Highcharts.chart('container', {
xAxis: {
type: 'datetime'
},
tooltip: {
xDateFormat: '%A, %B %d, %Y UTC ' + dayjs().format("Z") ,
shared: true
},
plotOptions: {
series: {
pointStart: Date.UTC(2012, 0, 1),
pointInterval: 24 * 3600 * 1000
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4].reverse()
}]
});
If you want to change what the UTC value is to the right you will want to write some code around that to create a variable and use concatenation or interpolation.
I used day.js, here are other ways you can get the timestamp from the browser. get client time zone from browser
There are a few resources around to do datetime formatting, I used this one: https://thoughtbot.com/blog/how-to-find-a-time-format-for-rubys-strftime
This is awesome, thanks heaps! Sidenote, the
%A
formatter to display the full day is not documented in Highcharts. But thanks to you I found out about that too! Cheers dude