I would like to group a simple date array by week and month (in an array). I know there are many examples, and the question has been asked many times, but I cannot find an example on a very simple date format, and not a date-time stamp.
My date data array looks like this:
"timeline_data": [
"2016-12-20",
"2016-12-21",
"2016-12-22",
"2016-12-23",
"2016-12-24",
"2016-12-25",
"2016-12-26",
"2016-12-27",
"2016-12-28",
"2016-12-29",
"2016-12-30",
"2016-12-31",
"2017-01-01",
"2017-01-02",
"2017-01-03",
"2017-01-04",
"2017-01-05",
"2017-01-06",
"2017-01-07",
"2017-01-08",
"2017-01-09",
"2017-01-10"
]
This is what is getting me: I am not sure whether there is an easy way of looping through this array, and simple pushing the items into new arrays, or whether the date will have to be modified, and the "-" removed with something like:
var date="2016-12-20";
var newDate = date.replace(/-/g, "");
And then obviously, the "-" will have to be replaced.
I hope there is a simpler way.