1. 程式人生 > >js 字串:"\/Date(1230739200000+0800)\/" 轉換成日期

js 字串:"\/Date(1230739200000+0800)\/" 轉換成日期

function formatDate(dt) {
var year = dt.getFullYear();
var month = dt.getMonth() + 1;
var date = dt.getDate();
var hour = dt.getHours();
var minute = dt.getMinutes();
var second = dt.getSeconds();
return year + “-” + month + “-” + date + ” ” + hour + “:” + minute + “:” + second;
}
function Test(time) {
var t= time.slice(6, 19)
var NewDtime = new Date(parseInt(t));
return formatDate(NewDtime);
}
Test(“/Date(1528953453022+0800)/”);