formatDate(nows) {
if (nows == null || nows == "") {
return "";
}
//nows = nows*1000; //视情况而定 如果是秒的话就不需要乘以1000
var now = new Date(nows);
var year = now.getFullYear();
var month = now.getMonth() + 1;
if (month.toString().length < 2) {
month = "0" + month;
}
var date = now.getDate();
if (date.toString().length < 2) {
date = "0" + date;
}
var hour = now.getHours();
if (hour.toString().length < 2) {
hour = "0" + hour;
}
var minute = now.getMinutes();
if (minute.toString().length < 2) {
minute = "0" + minute;
}
var second = now.getSeconds();
if (second.toString().length < 2) {
second = "0" + second;
}
return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
}