记录代码块:
formData(timestamp) {
const date = new Date(timestamp)
const Y = date.getFullYear() + '-'
const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
const D = date.getDate() + ' '
const h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':'
const m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':'
const s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return Y + M + D + h + m + s
}
timestamp 是 毫秒制,结果为
2017-06-20 17:36:43
网友评论