简单的时间初始化方法,适配element-ui
直接放代码
initDate(){
let now = new Date()
let y=now.getFullYear();
let m=now.getMonth() + 1 >9?now.getMonth() + 1 :"0"+(now.getMonth() + 1);
let d= now.getDate()>9?now.getDate() :"0"+now.getDate();
let h=now.getHours()>9?now.getHours() :"0"+now.getHours();
let i=now.getMinutes()>9?now.getMinutes() :"0"+now.getMinutes();
let s= now.getSeconds()>9?now.getSeconds() :"0"+now.getSeconds();
return y+'-'+m+'-'+d+' '+h+':'+i+':'+s
}