function getStringTime(time){
//年
year = time.getFullYear();
//月
month = time.getMonth()
if(String(month).length == 1){
month = "0"+month
}
//日
day = time.getDate();
if(String(day).length==1){
month= "0"+day;
}
//时
hour = time.getHours();
if(String(hour).length == 1){
hour = "0"+hour;
}
//分
minute = time.getMinutes()
if(String(minute).length == 1){
minute ="0"+minute;
}
//秒
second = time.getSeconds();
if(String(second).length ==1){
second = "0"+second;
}
t = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
return t;
}
result = getStringTime(time);
console.log(result);