function getDateStr(str) {
var oDate = new Date(parseInt(str.replace("/Date(", “”).replace(")/", “”), 10));
var oYear = oDate.getFullYear();
var oMonth = oDate.getMonth() + 1;
var oDay = oDate.getDate();
var oHour = oDate.getHours();
var oMin = oDate.getMinutes();
var oSen = oDate.getSeconds();
oTime = oYear + ‘-’ + getzf(oMonth) + ‘-’ + getzf(oDay) + ’ ’ + getzf(oHour) + ‘:’ + getzf(oMin) + ‘:’ + getzf(oSen);//最后拼接时间
return oTime;
};
function getzf(num) {
if (parseInt(num) < 10) {
num = ‘0’ + num;
}
return num;
}
Json从后台取得的时间格式如果是类似这种Date(1562653012000),可以采用以下方法转为字符串,查询多时,才综合出一个好用的。
最新推荐文章于 2019-08-15 21:59:58 发布