function getYearMonthDay(){
? ? var nowDays = new Date();
? ? var year = nowDays.getFullYear();? ? //年
? ? var month = nowDays.getMonth()+1? //月
? ? var day = nowDays.getDate() < 10 ? '0' + nowDays.getDate() : nowDays.getDate();
? ? //判斷月份是否為個位
????if(month <10){
? ? month = '0' + month;
? ? const startTime = year + '-' +? month + '-01' ;
? ? const endTime = year + month + day
? return {
? ??startTime:startTime;
? ??endTime:endTime;
}?
}
}
方法中進(jìn)行調(diào)用:const currentTime = getYearMonthDay();