10 回复
首先:看下回复吧(https://developers.weixin.qq.com/community/develop/doc/00062e819f0820c88349e55c55b800)
console.log(this.formatTime(new Date(1571499803000)))
打印出来是:2019/10/19 23:43:23
封装js:
formatTime(date) { var year = date.getFullYear() var month = date.getMonth() + 1 var day = date.getDate() var hour = date.getHours() var minute = date.getMinutes() var second = date.getSeconds() return [year, month, day].map(formatNumber).join( '/' ) + ' ' + [hour, minute, second].map(formatNumber).join( ':' ) } |