在做一个项目,拿到后台传过来的时间戳,已经转换成日期格式了,要如何渲染到页面上?html:<time id="delivery_time"></time>jq:function changeTime(time) { return new Date(parseInt(time) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");}$.ajax({ type: 'get', url: PointUrl + '/index.php?act=member_pointorder&op=order_info', data: { key: key, order_id: getQueryString('point_orderid') }, dataType: 'json', success: function(result) { checkLogin(result.login); var data = result.datas; var time = data.order_info.point_addtime; var localTime = changeTime(time); console.log(localTime); //这里可以打印出正确的日期格式 }});
1 回答
BIG阳
TA贡献1859条经验 获得超6个赞
$.ajax({
type: 'get',
url: PointUrl + '/index.php?act=member_pointorder&op=order_info',
data: {
key: key,
order_id: getQueryString('point_orderid')
},
dataType: 'json',
success: function(result) {
checkLogin(result.login);
var data = result.datas;
var time = data.order_info.point_addtime;
var localTime = changeTime(time);
console.log(localTime);
//这里可以打印出正确的日期格式
document.getElementById('delivery_time').innerHTML=localTime;//显示到节点里
}
});
添加回答
举报
0/150
提交
取消