hypeserver / react-date-range

A React component for choosing dates and date ranges.
MIT License
2.59k stars 672 forks source link

How to view current and previous months, not current and next months #268

Open AchinthaReemal opened 5 years ago

AchinthaReemal commented 5 years ago

Is there a way to show the current and previous months, not the current and next months ?

omelhoro commented 5 years ago

Any updates on this? Also curious

Dharnu commented 5 years ago

Any updates on this?

mikinw commented 4 years ago

if you are fine with only changing the initial range, a workaround could be:

const offsetInitialMonth = useCallback(node => { if (node !== null) { node.dateRange.calendar.changeShownDate(moment().subtract(1, "month").toDate()); } }, []);

<DateRangePicker ... ref={offsetInitialMonth} />

lexispike commented 3 years ago

For initial range, you can also just do:

<DateRangePicker
  ...
  shownDate={moment().subtract(1, 'month').toDate()}
/>

Would also love to be able to always show backwards-facing dates rather than forward facing.