方法1
new Date(parseInt(‘时间戳’) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ')
例:将1568168403转化为时间
console.log(new Date(parseInt(1568168403) * 1000).toLocaleString().replace(/:\d{1,2}$/,' '));
输出结果: 2019/9/11 上午10:20
方法2
封装函数times
function times(value) {
var date = new Date(parseInt(value) * 1000)
var tt = [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-') + ' ' + [date.getHours(), date.getMinutes()].join(':');
return tt;
}
//例:将1568168403转化为时间
times(1568168403);
即可转化为 2019-9-11 10:20