Getting all dates between a range #2933
Unanswered
cojoclaudiu
asked this question in
Q&A
Replies: 2 comments
-
Have you tried import { eachDayOfInterval } from "date-fns";
const start = new Date(2022, 0, 27);
const end = new Date(2022, 1, 3);
const res = eachDayOfInterval({ start, end });
console.log(res);
// 0: Thu Jan 27 2022 00:00:00 GMT-0500 (Eastern Standard Time)
// 1: Fri Jan 28 2022 00:00:00 GMT-0500 (Eastern Standard Time)
// 2: Sat Jan 29 2022 00:00:00 GMT-0500 (Eastern Standard Time)
// 3: Sun Jan 30 2022 00:00:00 GMT-0500 (Eastern Standard Time)
// 4: Mon Jan 31 2022 00:00:00 GMT-0500 (Eastern Standard Time)
// 5: Tue Feb 01 2022 00:00:00 GMT-0500 (Eastern Standard Time)
// 6: Wed Feb 02 2022 00:00:00 GMT-0500 (Eastern Standard Time)
// 7: Thu Feb 03 2022 00:00:00 GMT-0500 (Eastern Standard Time) |
Beta Was this translation helpful? Give feedback.
0 replies
-
@fturmel yes, but not the expected result. Here is my isolated code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, it is possible to get all days between a range of dates?
For example I would like to include the last dates from first month which are not in range but are in between the range. I'm using a library (react-day-picker) in the example which is using the date-fns but the think is I would like to include / select the dates which are between a range.
Beta Was this translation helpful? Give feedback.
All reactions