obtainTime(){
let date = new Date();
let time = ''
time+=date.getFullYear()+'-'
time+=(date.getMonth()+1)>=10 ? (date.getMonth()+1) : '0'+(date.getMonth()+1)+'-'
time+=date.getDate()>=10 ? date.getDate() : '0'+date.getDate()
time+=' '
time+=date.getHours()>=10 ? date.getHours() : '0'+date.getHours()
time+=':'
time+=date.getMinutes()>=10 ? date.getMinutes() : '0'+date.getMinutes()
time+=':'
time+=date.getSeconds()>=10 ? date.getSeconds() : '0'+date.getSeconds()
this.setState({
time:time
})
}
computeTime(){
setInterval(() => {
this.obtainTime()
}, 1000)
}
formateDate(time){
if(!time) return '';
let date = new Date(time)
return date.getFullYear() + '-' + (date.getMonth()+1).toString().padStart(2,'0')+'-'+date.getDate().toString().padStart(2,'0')+' '+date.getHours().toString().padStart(2,'0')+':'+date.getMinutes().toString().padStart(2,'0')+':'+date.getSeconds().toString().padStart(2,'0')
}