原数据:
结果:
var arr = [
{
"label": "00:00-00:15",
"count": 3
},
{
"label": "00:15-00:30",
"count": 3
},
{
"label": "12:00-12:15",
"count": 3
},
{
"label": "12:15-12:30",
"count": 3
},
{
"label": "12:30-12:45",
"count": 3
}
]
/**
* arr 原数据
* startDate 开始时间 默认传 00:00:00
* endDate 结束时间 默认传 00:30:00
*
*/
const getEchoTime = (arr,startDate,endDate) =>{
let newArr = [];
let start = startDate.substring(0,5);
let end = endDate.substring(0,5);
newArr = arr.filter(({label}) => {
const times = label.split('-');
return times[0] >= start && times[1] <= end;
})
return newArr;
}
console.log( getEchoTime(arr,'00:00:00','00:30:00'))
标签:count,00,12,15,arr,label,获取,区间,数据 From: https://www.cnblogs.com/zxh-bug/p/17014391.html