后台提供的时间格式是:2019-09-19T01:18:13.000+0000,我这边转换的格式代码为:
const formatDate = (date) =>{
var time = new Date(date);
var y,m,d,h,min,s;
y = time.getFullYear();
m = formatNumber(time.getMonth()+1);
d = formatNumber(time.getDate());
h = formatNumber(time.getHours());
min = formatNumber(time.getMinutes());
s = formatNumber(time.getSeconds());
return `${y}/${m}/${d} ${h}:${min}:${s}`
}
function formatNumber(n){
var time = n.toString()
return time < 10 ? “0”+n : n
}
网上说是替换 ‘-’ 为 ‘/’, date.replace(/\-/g, “/”) ,
但是试过之后都没有用,请各位看看是否能帮解决一下