/**
* 获取年月日 时分秒
*/
var getYMD = function (format) {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
if (month < 10) {
month = '0' + month
}
var date = now.getDate();
if (date < 10) {
date = '0' + date
}
var day = now.getDay(); //得到周几
var hour = now.getHours(); //得到小时
if (hour < 10) {
hour = '0' + hour
}
var minu = now.getMinutes(); //得到分钟
if (minu < 10) {
minu = '0' + minu
}
var sec = now.getSeconds(); //得到秒
if (sec < 10) {
sec = '0' + sec
}
var _time = ''
if (format == 1) {
_time = year + "-" + month + "-" + date
} else if (format == 2) {
_time = year + month + date + hour + minu + sec
} else {
_time = year + "-" + month + "-" + date + " " + hour + ":" + minu + ":" + sec
}
return _time
}
module.exports = {
getYMD: getYMD
}