前端时间格式转换2020-10-08T0:03:09.478Z
1效果
2方法一:原生方式
根据图1获取的字段createdAt
这里的this.userInfo.createdAt就是你需要转格式的数据
let time=new Date(+new Date(new Date(this.userInfo.createdAt).toJSON()) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
3方法二:函数方式
function getTime(date) {
var dateee = new Date(date).toJSON();
return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().