1

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;

                  }
},
user1471980
  • 10,127
  • 48
  • 136
  • 235
  • This might help. http://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript – JonnyS Jun 10 '13 at 18:52

1 Answers1

4

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;

                  }
},
Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297