//获取当前时间加两天(闰年 天数)
function getTimer() {
var str = ""
var timer = new Date()
var year = timer.getFullYear()
var month = timer.getMonth() + 1 < 10 ? "0" + (timer.getMonth() + 1) : timer.getMonth() + 1
var day = (timer.getDate() + 2) < 10 ? "0" + (timer.getDate() + 2) : timer.getDate() + 2
var hour = timer.getHours() < 10 ? "0" + timer.getHours() : timer.getHours()
var minute = timer.getMinutes() < 10 ? "0" + timer.getMinutes() : timer.getMinutes()
var second = timer.getSeconds() < 10 ? "0" + timer.getSeconds() : timer.getSeconds()
var erMonth = month
//二月
if (erMonth == "02") {
if (year % 4 == 0) {
if (day == 30) {
month = "03"
day = "01"
}
} else {
if (day == 29) {
month = "03"
day = "01"
}
}
}
//其他30天
if (erMonth == "04" || erMonth == "06" || erMonth == "09" || erMonth == "11") {
if (day == "31") {
month = timer.getMonth() + 2 < 10 ? "0" + (timer.getMonth() + 1) : timer.getMonth() + 2
day = "01"
}
} else {
if (day == "32") {
month = timer.getMonth() + 2 < 10 ? "0" + (timer.getMonth() + 1) : timer.getMonth() + 2
day = "01"
}
}
//年
if (erMonth == "13") {
year = year + 1
}
return str = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
}
console.log(getTimer());