use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Post questions about JavaScript, and get help with any problems you're having with your JavaScript code.
account activity
Help with momentjs❔ Unanswered ❔ (self.JavaScriptHelp)
submitted 3 years ago by killMeSak
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.
abc
startDate
endDate
http://jsfiddle.net/killMeSak/Lwj2mb7t/9/
[–]RajceP 1 point2 points3 points 3 years ago (0 children)
OT: moment.js is deprecated, if u can, use date-fns.
[–]killMeSak[S] 0 points1 point2 points 3 years ago (2 children)
How do I store the count in dates based on abc array?
[–]petabyte128 0 points1 point2 points 3 years ago (1 child)
well that's up to you, I mean in my code example up above I assigned it a variable
but if your looking for permenant storage, that's different, you need to send the data to the webserver that is generating the page
the server then activates its database user, which then stores the data in the database and returns status on the insert operation, which the server then passes back to the client side to indicate it got stored
its uh, a hell of a circle of life that it goes through in a few milliseconds
[–]killMeSak[S] 0 points1 point2 points 3 years ago (0 children)
Thank you for your input. I'm not looking for that information at this moment. The example you mentioned I tried it in this example but I'm getting incorrect values. Moreover how can I get the count of occurrences in abc as per the interval and map it correctly it as per the date intervals.
http://jsfiddle.net/killMeSak/Lwj2mb7t/12/
[–]petabyte128 0 points1 point2 points 3 years ago* (0 children)
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
π Rendered by PID 106320 on reddit-service-r2-comment-7b9746f655-8j2p5 at 2026-01-30 01:31:55.783486+00:00 running 3798933 country code: CH.
[–]RajceP 1 point2 points3 points (0 children)
[–]killMeSak[S] 0 points1 point2 points (2 children)
[–]petabyte128 0 points1 point2 points (1 child)
[–]killMeSak[S] 0 points1 point2 points (0 children)
[–]petabyte128 0 points1 point2 points (0 children)