Reputation: 10636
I am building a chart using highcharts. Values on xaxis are epoch format. When I try to show the values, it comes up as epoch. How would I convert to this to readable format in javascript. This is what I have:
tooltip: {
enabled: true,
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y;
}
},
Upvotes: 1
Views: 2954
Reputation: 110922
You can use the Highcharts.dateFormat
function. Note you have to multiply your epoch number with 1000, as Highcharts.dateFormat
needs a JavaScript date timestamp (milliseconds since Jan 1st 1970).
tooltip: {
enabled: true,
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%d.%m.%Y', this.x*1000) +': '+ this.y;
}
},
Upvotes: 4