微信开发者工具和线上预览是正常的
体验版和正式版失效
只能自己一点一点拼接
let d = new Date()
let year = d.getFullYear()
let month = d.getMonth() + 1
let day = d.getDate()
let date = `${year+'-'+month +'-'+day}` // 2023-8-14
我写的
for (let i = 0; i < res.list.length; i++) {
res.list[i].lastTime = (new Date(parseInt(res.list[i].lastTime)).getMonth() + 1 < 10 ? '0' + (new Date(parseInt(res.list[i].lastTime)).getMonth() + 1) : new Date(parseInt(res.list[i].lastTime)).getMonth() + 1)
+ '-' + (new Date(parseInt(res.list[i].lastTime)).getDate() + 1 < 10 ? '0' + (new Date(parseInt(res.list[i].lastTime)).getDate() + 1) : new Date(parseInt(res.list[i].lastTime)).getDate() + 1)
+ " " + (new Date(parseInt(res.list[i].lastTime)).getHours() + 1 < 10 ? '0' + (new Date(parseInt(res.list[i].lastTime)).getHours() + 1) : new Date(parseInt(res.list[i].lastTime)).getHours() + 1)
+ ':' + (new Date(parseInt(res.list[i].lastTime)).getMinutes() + 1 < 10 ? '0' + (new Date(parseInt(res.list[i].lastTime)).getMinutes() + 1) : new Date(parseInt(res.list[i].lastTime)).getMinutes() + 1)
}