时间格式转换2020-01-01 00:00:00

240 阅读1分钟
// 获取当前时间并转换为需要的格式 2020-01-01 00:00:00​    
function time(time = +new Date()) {​        
    console.log(time)​        
    var date = new Date(time + 8 * 3600 * 1000); // 增加8小时​        
    return date.toJSON().substr(0, 19).replace('T', ' ');​     
}