function
dateFormateStr(
obj){
console.
log(
typeof
obj.
getMonth());
if(
Number(
obj.
getMonth()) <
9){
return
obj.
getFullYear() +
"-0" + (
obj.
getMonth() +
1) +
"-" +
obj.
getDate() +
" " +
obj.
getHours() +
":" +
obj.
getMinutes() +
":" +
obj.
getSeconds();
}
else{
return
obj.
getFullYear() +
"-" + (
obj.
getMonth() +
1) +
"-" +
obj.
getDate() +
" " +
obj.
getHours() +
":" +
obj.
getMinutes() +
":" +
obj.
getSeconds();
}
}
function
dateFormateNum (
obj) {
if(
Number(
obj.
getMonth()) <
9){
return
Number(
obj.
getFullYear() +
"0" + (
obj.
getMonth() +
1));
}
else{
return
Number(
obj.
getFullYear() +
"" + (
obj.
getMonth() +
1));
}
}
let
a
=
new
Date
();
a.
setMonth(
10);
console.
log(
dateFormateStr(
a));
console.
log(
dateFormateNum(
a),
typeof
dateFormateNum(
a));