function fillZero(str) {
var realNum;
if (str < 10) {
realNum = "0" + str;
} else {
realNum = str;
}
return realNum;
}
function getNowTime() {
let now = new Date();
let year = now.getFullYear();
let month = now.getMonth() + 1;
let today = now.getDate();
let hour = now.getHours();
let minute = now.getMinutes();
let second = now.getSeconds();
let nowTime = "";
nowTime =
year +
"-" +
fillZero(month) +
"-" +
fillZero(today) +
" " +
fillZero(hour) +
":" +
fillZero(minute) +
":" +
fillZero(second);
return nowTime;
}
console.log(getNowTime())
console