当月第一天的日期
handleTimeOld (time, split) {
let date = new Date(time)
let year = date.getFullYear()
let month = date.getMonth() + 1
split = '-'
return [year, month, 1].map(num => this.formatNumber(num)).join(split)
}
今天的日期
handleTimeNew (time) {
let date = new Date(time)
let year = date.getFullYear()
let month = (date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1))
let day = date.getDate() >= 10 ? date.getDate() : ('0' + date.getDate())
return `${year}-${month}-${day}`
}
调用:
this.search.beginDate = this.handleTimeOld(new Date()) //2018-12-1
this.search.endDate = this.handleTimeNew(new Date()) //2018-12-1
只能怪今天是2018年12月1日 当天是这个日子,最后一天也是,哈哈哈
保护眼睛,锻炼身体