How to convert 1304921325178.3193
to yyyy-mm-dd
-> in javascript?
I use highchart and I would like to convert data(xAxis[0]0)
to yyyy-mm-dd
.
I tried to parse the millisecond using this function
function(valTime) {
var date = new Date(valTime);
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
m = (m < 10) ? '0' + m : m;
d = (d < 10) ? '0' + d : d;
return [y, m, d].join('-');
}
However, there is a gap between actual date(2015-01-26) and selected date in the chart (2015-01-29). captured image I guess if I calculate .3193, the date will be matched.
Is there any way to get the right date from the millisecond?