10位时间戳用js怎么转成年月日时分秒格式?
1、示例代码
function transTime(param) {
var sd = new Date(param)
var year = sd.getFullYear()
var month = sd.getMonth() + 1
var day = sd.getDate()
var hour = sd.getHours()
var minute = sd.getMinutes()
var second = sd.getSeconds()
return `${year}-${month < 10? '0'+month:month}-${day < 10?'0'+day:day} ${hour < 10?'0'+hour:hour}:${minute < 10? '0' + minute:minute}:${second <尺亩 10? '0'陵亏森 + second: second}`
}
var date = new Date().getTime()
var sdat = date.toString().substring(0,10)
var ame = transTime(parseInt(sdat))
console.log(ame)
2、示例空胡结果
1970-01-19 21:43:48