// 时间戳转换成时间格式
let date = new Date(times); // times 时间戳(通常为13位)
let Y = date.getFullYear();
let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) ;
let D = (date.getDate() < 10 ?'0'+ date.getDate() : date.getDate());
let H = date.getHours() < 10 ?'0'+ date.getHours() : date.getHours();
let Min = date.getMinutes() < 10 ?'0'+ date.getMinutes() : date.getMinutes();
let S = date.getSeconds() < 10 ?'0'+ date.getSeconds() : date.getSeconds();
let times = Y + '-'+ M+ '-' + D+' ' + H + ':'+ Min+ ':' + S;
return times; // eg: 2018-08-02 09:30:12
网友评论