//时间戳转换
formatDate(now) {
var date = new Date(now);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
var year = date.getFullYear(),
month = ("0" + (date.getMonth() + 1)).slice(-2),
sdate = ("0" + date.getDate()).slice(-2),
hour = ("0" + date.getHours()).slice(-2),
minute = ("0" + date.getMinutes()).slice(-2),
second = ("0" + date.getSeconds()).slice(-2);
// 拼接
var result = year + "-"+ month +"-"+ sdate +" "+ hour +":"+ minute +":" + second;
// 返回
return result;
}
2020-01-01T00:00:00.000000Z 日期格式转换
rTime(date) {
var json_date = new Date(date).toJSON();
return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
}
console.log(rTime(2021-05-27T00:00:00.000+0000))