getYMDHMS(timestamp){lettime=newDate(timestamp)letyear=time.getFullYear()letmonth=time.getMonth()+1letdate=time.getDate()lethours=time.getHours()letminute=复制代码time.getMinutes()letsecond=time.getSeconds()if(month<10){month='0'+month}if(date<10){date='0'+date}if(hours<10){hours='0'+hours}if(minute<10){minute='0'+minute}if(second<10){second='0'+second}return年+'-'+月+'-'+date+''+hours+':'+minute+':'+second}//使用es6的padStart()方法来补充0getYMDHMS(timestamp){lettime=newDate(timestamp)letyear=time.getFullYear()constmonth=(time.getMonth()+1).toString().padStart(2,'0')constdate=(time.getDate()).toString().padStart(2,'0')consthours=(time.getHours()).toString().padStart(2,'0')constminute=(time.getMinutes()).toString().padStart(2,'0')constsecond=(time.getSeconds()).toString().padStart(2,'0')返回年+'-'+月+'-'+日期+''+小时+':'+分钟+':'+秒}
