时间截转换成年月日时分秒"xxxx-xx-xx xx:xx:xx"
formatDate(now) {
const d = new Date(Number(now) * 1000);
const year = this.timeChange(d.getFullYear());
const month = this.timeChange(d.getMonth() + 1);
const date = this.timeChange(d.getDate());
const hour = this.timeChange(d.getHours());
const minute = this.timeChange(d.getMinutes());
const second = this.timeChange(d.getSeconds());
return (
year +
"-" +
month +
"-" +
date +
" " +
hour +
":" +
minute +
":" +
second
);
},
timeChange(num) {
return ((num >= 10) ? num : `0${num}`);
},