调用
console.log(this.getSectionData(7))
结果
函数
getSectionData(section) {
const now = new Date()
const nowYear = now.getFullYear()
const nowMonth = now.getMonth() + 1 < 10 ? ('0' + (now.getMonth() + 1)) : (now.getMonth() + 1)
const nowDay = now.getDate() < 10 ? ('0' + now.getDate()) : now.getDate()
let newDate = new Date();
newDate.setDate(newDate.getDate() + section);
const newYear = newDate.getFullYear()
const newMonth = newDate.getMonth() + 1 < 10 ? ('0' + (newDate.getMonth() + 1)) : (newDate.getMonth() + 1)
const newDay = newDate.getDate() < 10 ? ('0' + newDate.getDate()) : newDate.getDate()
return [nowYear + '-' + nowMonth + '-' + nowDay + ' 00:00:00', newYear + '-' + newMonth + '-' + newDay +
' 23:23:23'
]
},