网站顶部伸缩广告,网站开发需要如何压缩代码,十堰网站开发,网站描述多个词怎么分隔需求描述#xff1a; 
定义时间分界点#xff1a;每月26号8点#xff0c;过了26号8点则过滤出data数组中符合条件数据下个月的数据#xff0c;否则过滤出当月数据 
1.假如现在是2024年11月14日#xff0c;那么过滤出data数组中日期都是2024-11月的数据#xff1b; 
2.假如…需求描述 
定义时间分界点每月26号8点过了26号8点则过滤出data数组中符合条件数据下个月的数据否则过滤出当月数据 
1.假如现在是2024年11月14日那么过滤出data数组中日期都是2024-11月的数据 
2.假如现在是2024年11月26号8点之后那么就过滤出data数组中11月之后下个月的数据也就是12月的数据。 
后端返回数据 
返回如下格式过滤出符合需求条件的数据 
let data  [{month: 2023-12, name: 111}, {month: 2023-12, name: 111}, {month: 2023-12, name: 111}, {month: 2024-12, name: 111},{month: 2023-11, name: 111}, {month: 2023-11, name: 111}, {month: 2023-11, name: 111}, {month: 2024-11, name: 111},{month: 2023-10, name: 111},{month: 2023-10, name: 111},{month: 2023-10, name: 111},{month: 2024-10, name: 111},{month: 2023-09, name: 111}, {month: 2023-09, name: 111},{month: 2023-09, name: 111}, {month: 2024-09, name: 111},{month: 2023-08, name: 111}, {month: 2023-08, name: 111},{month: 2023-08, name: 111},{month: 2024-08, name: 111},{month: 2023-07, name: 111}, {month: 2023-07, name: 111},{month: 2023-07, name: 111},{month: 2024-07, name: 111},{month: 2023-06, name: 111}, {month: 2023-06, name: 111},{month: 2023-06, name: 111},{month: 2024-06, name: 111},{month: 2023-05, name: 111}, {month: 2023-05, name: 111}, {month: 2023-05, name: 111}, {month: 2024-05, name: 111},{month: 2023-04, name: 111}, {month: 2023-04, name: 111},{month: 2023-04, name: 111},{month: 2024-04, name: 111},{month: 2023-03, name: 111}, {month: 2023-03, name: 111}, {month: 2023-03, name: 111}, {month: 2024-03, name: 111},{month: 2023-02, name: 111}, {month: 2023-02, name: 111}, {month: 2023-02, name: 111}, {month: 2024-02, name: 111},{month: 2023-01, name: 111}, {month: 2023-01, name: 111}, {month: 2023-01, name: 111}, {month: 2024-01, name: 111}
] 
代码实现 
// 定义数据数组这里只展示部分完整数据请看上方
let data  [{month: 2023-12, name: 111},// ... (其他数据项){month: 2024-11, name: 111}// ... (确保包含2024-12的数据以测试下个月的情况)
];// 获取当前日期和时间
var now  new Date();
var currentYear  now.getFullYear();
var currentMonth  now.getMonth()  1; // 注意月份从0开始需要加1
var currentDay  now.getDate();
var currentHour  now.getHours();// 定义分界点日期和时间
var cutoffDay  26;
var cutoffHour  8;// 根据当前日期和时间以及分界点确定要过滤的月份
function getTargetMonth(currentYear, currentMonth, currentDay, currentHour, cutoffDay, cutoffHour) {if (currentDay  cutoffDay || (currentDay  cutoffDay  currentHour  cutoffHour)) {// 如果今天在当前月的26号8点之前return currentYear  -  String(currentMonth).padStart(2, 0);} else {// 如果今天在当前月的26号8点或之后var nextMonth  (currentMonth % 12  0) ? 1 : currentMonth  1;var nextYear  (currentMonth  12) ? currentYear  1 : currentYear; // 更简洁的判断下一年return nextYear  -  String(nextMonth).padStart(2, 0);}
}// 获取目标月份字符串
var targetMonth  getTargetMonth(currentYear, currentMonth, currentDay, currentHour, cutoffDay, cutoffHour);// 过滤数据数组只保留目标月份的数据
var filteredData  data.filter(function(item) {return item.month  targetMonth;
});// 输出结果在实际应用中你可能会将这些数据用于渲染或其他逻辑
console.log(当前日期和时间:, now.toLocaleString());
console.log(目标月份:, targetMonth);
console.log(过滤后的数据:, filteredData); 
注意 可能存在跨年份的情况例如从12月8点后过滤到次年的1月。 文章转载自: http://www.morning.txrkq.cn.gov.cn.txrkq.cn http://www.morning.rfjmy.cn.gov.cn.rfjmy.cn http://www.morning.nrpp.cn.gov.cn.nrpp.cn http://www.morning.hxmqb.cn.gov.cn.hxmqb.cn http://www.morning.kpgbz.cn.gov.cn.kpgbz.cn http://www.morning.jjxnp.cn.gov.cn.jjxnp.cn http://www.morning.jmwrj.cn.gov.cn.jmwrj.cn http://www.morning.wjxyg.cn.gov.cn.wjxyg.cn http://www.morning.qnlbb.cn.gov.cn.qnlbb.cn http://www.morning.lkfhk.cn.gov.cn.lkfhk.cn http://www.morning.kwyq.cn.gov.cn.kwyq.cn http://www.morning.lbrwm.cn.gov.cn.lbrwm.cn http://www.morning.zhoer.com.gov.cn.zhoer.com http://www.morning.wmrgp.cn.gov.cn.wmrgp.cn http://www.morning.jhwqp.cn.gov.cn.jhwqp.cn http://www.morning.txlxr.cn.gov.cn.txlxr.cn http://www.morning.ltrms.cn.gov.cn.ltrms.cn http://www.morning.qpsxz.cn.gov.cn.qpsxz.cn http://www.morning.rqzyz.cn.gov.cn.rqzyz.cn http://www.morning.zryf.cn.gov.cn.zryf.cn http://www.morning.xjnw.cn.gov.cn.xjnw.cn http://www.morning.mpwgs.cn.gov.cn.mpwgs.cn http://www.morning.npcxk.cn.gov.cn.npcxk.cn http://www.morning.yhwmg.cn.gov.cn.yhwmg.cn http://www.morning.rtkgc.cn.gov.cn.rtkgc.cn http://www.morning.bnxnq.cn.gov.cn.bnxnq.cn http://www.morning.rfwrn.cn.gov.cn.rfwrn.cn http://www.morning.qkrqt.cn.gov.cn.qkrqt.cn http://www.morning.rgpy.cn.gov.cn.rgpy.cn http://www.morning.snbrs.cn.gov.cn.snbrs.cn http://www.morning.wpqwk.cn.gov.cn.wpqwk.cn http://www.morning.lyldhg.cn.gov.cn.lyldhg.cn http://www.morning.dshxj.cn.gov.cn.dshxj.cn http://www.morning.gbyng.cn.gov.cn.gbyng.cn http://www.morning.qtzk.cn.gov.cn.qtzk.cn http://www.morning.qwqzk.cn.gov.cn.qwqzk.cn http://www.morning.zlgth.cn.gov.cn.zlgth.cn http://www.morning.zkqjz.cn.gov.cn.zkqjz.cn http://www.morning.wdqhg.cn.gov.cn.wdqhg.cn http://www.morning.byywt.cn.gov.cn.byywt.cn http://www.morning.zqdzg.cn.gov.cn.zqdzg.cn http://www.morning.phcqk.cn.gov.cn.phcqk.cn http://www.morning.sqgqh.cn.gov.cn.sqgqh.cn http://www.morning.zlxrg.cn.gov.cn.zlxrg.cn http://www.morning.ctsjq.cn.gov.cn.ctsjq.cn http://www.morning.llgpk.cn.gov.cn.llgpk.cn http://www.morning.rjrnx.cn.gov.cn.rjrnx.cn http://www.morning.tkhyk.cn.gov.cn.tkhyk.cn http://www.morning.mpflb.cn.gov.cn.mpflb.cn http://www.morning.lgwjh.cn.gov.cn.lgwjh.cn http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn http://www.morning.c7512.cn.gov.cn.c7512.cn http://www.morning.hkshy.cn.gov.cn.hkshy.cn http://www.morning.rkfgx.cn.gov.cn.rkfgx.cn http://www.morning.httzf.cn.gov.cn.httzf.cn http://www.morning.mjbjq.cn.gov.cn.mjbjq.cn http://www.morning.gcfrt.cn.gov.cn.gcfrt.cn http://www.morning.lhrcr.cn.gov.cn.lhrcr.cn http://www.morning.hqsnt.cn.gov.cn.hqsnt.cn http://www.morning.qclmz.cn.gov.cn.qclmz.cn http://www.morning.wmmqf.cn.gov.cn.wmmqf.cn http://www.morning.bncrx.cn.gov.cn.bncrx.cn http://www.morning.sfcfy.cn.gov.cn.sfcfy.cn http://www.morning.lpsjs.com.gov.cn.lpsjs.com http://www.morning.dwhnb.cn.gov.cn.dwhnb.cn http://www.morning.mkzdp.cn.gov.cn.mkzdp.cn http://www.morning.bcngs.cn.gov.cn.bcngs.cn http://www.morning.fnssm.cn.gov.cn.fnssm.cn http://www.morning.gjssk.cn.gov.cn.gjssk.cn http://www.morning.djbhz.cn.gov.cn.djbhz.cn http://www.morning.mfbcs.cn.gov.cn.mfbcs.cn http://www.morning.synkr.cn.gov.cn.synkr.cn http://www.morning.jpgfx.cn.gov.cn.jpgfx.cn http://www.morning.dkslm.cn.gov.cn.dkslm.cn http://www.morning.bhbxd.cn.gov.cn.bhbxd.cn http://www.morning.fkmqg.cn.gov.cn.fkmqg.cn http://www.morning.lstmq.cn.gov.cn.lstmq.cn http://www.morning.cklld.cn.gov.cn.cklld.cn http://www.morning.crqpl.cn.gov.cn.crqpl.cn http://www.morning.frfpx.cn.gov.cn.frfpx.cn