0

I have an array of strings in this format: "2023-01-30". The dates range from past, to present, to future. I want to sort the dates into separate arrays based on the work weeks (monday through friday) that they fall into with past weeks falling into the present week.

For instance, given the array ["2022-02-15", 2023-01-30", "2023-02-03", "2023-02-06", "2023-02-14"] I want to sort into a 2d array with the first array being this week and all past events, and following arrays being subsequent weeks: [["2022-02-15", 2023-01-30", "2023-02-03"], ["2023-02-06"], ["2023-02-14"]]. I'm trying to use the js Date() object to accomplish this but something in my logic is off. Thanks in advance!

JBrown
  • 825
  • 6
  • 22
  • 1
    So the groups are 1. Everything up to the end of the current week 2. Everything within the next week 3. Everything within the week after the next week, correct? If so, related: [Get week of year in JavaScript like in PHP](/q/6117814/4642212). – Sebastian Simon Jan 30 '23 at 21:16

0 Answers0