时间戳转年月日时分秒
作者:互联网
add0 (m) { return m < 10 ? '0' + m : m }, // 时间戳转日期 format (time) { // shijianchuo是整数,否则要parseInt转换 var time1 = new Date(time) var year = time1.getFullYear() var month = time1.getMonth() + 1 var day = time1.getDate() let h = time1.getHours() >= 10 ? time1.getHours() : '0' + time1.getHours() let m = time1.getMinutes() >= 10 ? time1.getMinutes() : '0' + time1.getMinutes() // let s = time1.getSeconds() >= 10 ? time1.getSeconds() : '0' + time1.getSeconds() return year + '-' + this.add0(month) + '-' + this.add0(day) + ' ' + h + ':' + m }
标签:10,getMinutes,getSeconds,getHours,time1,时间,var,年月日,时分秒 来源: https://www.cnblogs.com/everseventh/p/16700532.html