时间戳转时间格式

时间:2022-07-03 02:33:51

//转时间格式
function getDateTime(date) {
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hh = date.getHours();
var mm = date.getMinutes();
var ss = date.getSeconds();
return year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
}

使用方法;

getDateTime(new Date(时间戳));