[英]how do you convert epoch to readable date format in javascript
I am building a chart using highcharts. 我正在使用highcharts构建图表。 Values on xaxis are epoch format. xaxis上的值是epoch格式。 When I try to show the values, it comes up as epoch. 当我试图展示价值时,它会成为时代。 How would I convert to this to readable format in javascript. 我将如何在javascript中将其转换为可读格式。 This is what I have: 这就是我所拥有的:
tooltip: {
enabled: true,
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y;
}
},
You can use the Highcharts.dateFormat
function. 您可以使用Highcharts.dateFormat
函数。 Note you have to multiply your epoch number with 1000, as Highcharts.dateFormat
needs a JavaScript date timestamp (milliseconds since Jan 1st 1970). 请注意,您必须将您的纪元数乘以1000,因为Highcharts.dateFormat
需要一个JavaScript日期时间戳(自1970年1月1日以来的毫秒数)。
tooltip: {
enabled: true,
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%d.%m.%Y', this.x*1000) +': '+ this.y;
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.