标签:日期格式 pre this second mat 转换 new time 日期格
let time=1614733234043
let newTime=this.formatDate(time)
formatDate(date) {
let nowdate = new Date(date);
let YY = nowdate.getFullYear() + ‘-‘;
let MM = (nowdate.getMonth() + 1 < 10 ? ‘0‘ + (nowdate.getMonth() + 1) : nowdate.getMonth() + 1) + ‘-‘;
let DD = (nowdate.getDate() < 10 ? ‘0‘ + (nowdate.getDate()) : nowdate.getDate());
let hh = (nowdate.getHours() < 10 ? ‘0‘ + nowdate.getHours() : nowdate.getHours()) + ‘:‘;
let mm = (nowdate.getMinutes() < 10 ? ‘0‘ + nowdate.getMinutes() : nowdate.getMinutes()) + ‘:‘;
let ss = (nowdate.getSeconds() < 10 ? ‘0‘ + nowdate.getSeconds() : nowdate.getSeconds());
return YY + MM + DD +" "+hh + mm + ss;
},
标签:日期格式 pre this second mat 转换 new time 日期格
原文地址:https://www.cnblogs.com/xb130460/p/14472525.html