[英]how do you convert epoch to readable date format in javascript
我正在使用highcharts構建圖表。 xaxis上的值是epoch格式。 當我試圖展示價值時,它會成為時代。 我將如何在javascript中將其轉換為可讀格式。 這就是我所擁有的:
tooltip: {
enabled: true,
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y;
}
},
您可以使用Highcharts.dateFormat
函數。 請注意,您必須將您的紀元數乘以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.