functiongetdate(){var now =newDate(),
y = now.getFullYear(),
m =("0"+(now.getMonth()+1)).slice(-2),
d =("0"+ now.getDate()).slice(-2);return y +"-"+ m +"-"+ d +" "+ now.toTimeString().substr(0,8);}
正则时间格式化
var date ="2018-10-08 15:22:45";//格式化掉 时分秒var newDate=/\d{4}-\d{1,2}-\d{1,2}/g.exec(date)//格式化掉秒var newDate=/\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}/g.exec(date)