编辑代码

/**
 * 补零操作函数
 * @author WEI.ZHOU
 * @version V1.0.0
 */
function repairZero(m) {
    return m < 10 ? '0' + m : m
}

/**
 * 时间戳转换时间格式(注意时间戳只能是13位的时间戳) 
 * @author WEI.ZHOU
 * @version V1.0.0
 */
function timeZoneTomoment(dataBaseTime) {
    let timeObject = new Date(Number(dataBaseTime));
    return timeObject.getFullYear() + '-' + repairZero(timeObject.getMonth() + 1) + '-' + 
            repairZero(timeObject.getDate()) + ' ' + repairZero(timeObject.getHours()) + ':' + 
            repairZero(timeObject.getMinutes()) + ':' + repairZero(timeObject.getSeconds());
}

/**
 * 时间戳转换测试 数字类型
 */
console.log(timeZoneTomoment(1648451025000));

/**
 * 时间戳转换测试 字符串类型
 */
console.log(timeZoneTomoment("1648451025000"));