格式化时间
function newTime() {
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var dates = date.getDate();
var hours = date.getHours();
hours = hours < 10 ? '0' + hours : hours;
var min = date.getMinutes();
min = min < 10 ? '0' + min : min;
var miao = date.getSeconds();
miao = miao < 10 ? '0' + miao : miao;
return year + '-' + month + '-' + dates + ' ' + hours + ':' + min + ':' + miao;
}
console.log(newTime());