我的数据看起来像这样(/Date(1500921000000)/
),我想转换为Date。如何IDK。请帮帮我
答案 0 :(得分:0)
您可以尝试此代码
//DEFINE THE FUNCTION TO GET DATE FROM MILISECOND
var format = function (time, format) {
var t = new Date(time);
var tf = function (i) { return (i < 10 ? '0' : '') + i };
return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) {
switch (a) {
case 'yyyy':
return tf(t.getFullYear());
break;
case 'MM':
return tf(t.getMonth() + 1);
break;
case 'mm':
return tf(t.getMinutes());
break;
case 'dd':
return tf(t.getDate());
break;
case 'HH':
return tf(t.getHours());
break;
case 'ss':
return tf(t.getSeconds());
break;
}
})
}
//ALERT THE OUTPUT OF "1500921000000" MILISECOND
alert(format(new Date(1500921000000).getTime(), 'MM/dd/yyyy'))
尝试然后让我知道结果,谢谢