// 获取上个月的第一天和最后一天
monthDayorEnd () {
const Date1 = new Date();
const year = Date1.getFullYear();
const month = Date1.getMonth();
Date1.setMonth(month - 1, 1);
this.startDate = Date1;
this.endDate = new Date(year, month, 0);
// this.MinRangeDate = `${this.formatDateYear(this.startDate)}年${this.formatDate(this.startDate)}-${this.formatDate(this.endDate)}`;
},
// 获取本月的第一天和最后一天
startEndTime () {
const nowdays = new Date();
const year = nowdays.getFullYear();
let month = nowdays.getMonth() + 1;
const day = nowdays.getDate();
month = month > 9 ? month : '0' + month;
nowdays.setTime(nowdays.getTime() - 24 * 60 * 60 * 1000 * (day - 1));// 获取当前月份第一天
this.startDate = nowdays;
this.endDate = new Date(year, month, 0);// 获取当前月份最后一天
this.MinRangeDate = `${this.formatDateYear(this.startDate)}年${this.formatDate(this.startDate)}-${this.formatDate(this.endDate)}`;
this.searchPay();// 调查询接口
},
formatDateYear (date) {
return `${date.getFullYear()}`;
},
formatDate (date) {
return `${date.getMonth() + 1}月${date.getDate()}日`;
},
dateFormatStart (time) {
var date = new Date(time);
var year = date.getFullYear();
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
// 拼接
return year + '-' + month + '-' + day + ' ' + '00' + ':' + '00' + ':' + '00';
},
//获取7天
getBeforeDate (beforeDate = 0) {
const time = new Date();
time.setTime(time.getTime() - 24 * 60 * 60 * 1000 * beforeDate);
return time;
},
日期时间本月,上月,和某天前的函数
最新推荐文章于 2023-03-30 10:19:03 发布