【发布时间】:2018-10-23 08:11:17
【问题描述】:
目前我正在导入 Moment 和 Moment 范围,如下所示, 需要给定 2 个日期之间的日期数组,以便可以迭代日期
import Moment from 'moment';
import {extendMoment} from 'moment-range';
import React, {Component} from 'react';
class T extends Component {
constructor(props) {
const start = moment("2018-10-14", 'YYYY-MM-DD');
const end = moment("2018-10-20", 'YYYY-MM-DD');
const range = moment.range(start, end);
//need an array of dates in'YYYY-MM-DD' to itarate
}
}
【问题讨论】:
-
看看 moment-range 的
by,它在给定时间段内迭代你的范围。
标签: javascript arrays reactjs momentjs