r/JavaScriptHelp • u/killMeSak • Mar 12 '22
❔ Unanswered ❔ Help with momentjs
I've an array abc containing date and time. How can I convert it into time slots of 1 day with limits determined by startDate and endDate with 'x' containing time slots and 'y' containing count of occurrence in those time slots. I have also attached the fiddle below for reference.
2
Upvotes
2
1
u/petabyte128 Mar 12 '22 edited Mar 13 '22
var a = moment(start);
var b = moment(end);
let moments=Array(a.diff(b,'days')).fill(0).map((e,i)=>{return a.add(i,'d');});they'll already be in order start to finish, so you can use their array index as the 'y' value
1
u/killMeSak Mar 12 '22
How do I store the count in dates based on abc array?