我使用字典数组,我想按时间段对数据进行分组,我有一个解决方法。
但是现在我发现了问题,最后几个小时的数据没有出现在分组数组中。
代码:
// Dictionary array:
var array = [
{ item: "item", category: "category", dateTime: "19/05/23 05:46:33" },
{ item: "item", category: "category", dateTime: "19/05/23 05:21:33" },
{ item: "item", category: "category", dateTime: "19/05/23 06:31:33" },
{ item: "item", category: "category", dateTime: "19/05/23 06:46:33" },
{ item: "item", category: "category", dateTime: "19/05/23 07:34:33" },
{ item: "item", category: "category", dateTime: "19/05/23 07:55:33" },
{ item: "item", category: "category", dateTime: "19/05/23 08:46:33" },
{ item: "item", category: "category", dateTime: "19/05/23 09:16:33" },
{ item: "item", category: "category", dateTime: "19/05/23 09:46:33" },
{ item: "item", category: "category", dateTime: "19/05/23 10:36:33" },
{ item: "item", category: "category", dateTime: "19/05/23 11:47:33" },
{ item: "item", category: "category", dateTime: "19/05/23 11:55:33" },
{ item: "item", category: "category", dateTime: "19/05/23 12:37:33" },
{ item: "item", category: "category", dateTime: "19/05/23 14:27:33" },
{ item: "item", category: "category", dateTime: "19/05/23 14:37:33" },
];
因此,正如您在数组中看到的那样,我在过滤数据后的时间为 14:00 - 14:45 的数据未正确显示。
在我的数组中,我有两条记录:
{ item: "item", category: "category", dateTime: "19/05/23 14:27:33" },
{ item: "item", category: "category", dateTime: "19/05/23 14:37:33" },
我试图找到解决方案,但我卡住了。
预期输出:
{
"time": "14:00 - 14:45",
"groupedData": [{ item: "item", category: "category", dateTime: "19/05/23 14:27:33" },
{ item: "item", category: "category", dateTime: "19/05/23 14:37:33" }]
}
慕运维8079593
湖上湖
肥皂起泡泡
相关分类