【发布时间】:2021-05-06 23:27:30
【问题描述】:
我在这里有一个时间段列表,例如:
const times = [
{ start: '2020-07-09T08:00:00.000+02:00', end: '2020-07-09T09:30:00.000+02:00' },
{ start: '2020-07-09T08:30:00.000+02:00', end: '2020-07-09T10:00:00.000+02:00' },
]
当我尝试使用 momentjs 和 lodash 每天对它们进行 排序 以获得类似的东西时:
{
{startTime: '08:00', endTime: '08:30'}
{startTime: '08:30', endTime: '09:00'}
{startTime: '08:00', endTime: '08:30'}
{startTime: '08:30', endTime: '09:00'}
}
我现在最终得到了这个解决方案:
const groupedAndFormatted = groupBy(times, date => moment(date.start_time).startOf('day').format('MMM Do YY'))
但是这个并没有真正给我正确的解决方案,有什么想法吗?
【问题讨论】:
标签: javascript momentjs lodash