[{"id":"15","heading":"Post1","content":"Post 1 Content","date":"2016-11-09 08:51:37"}, {"id":"16","heading":"Post2","content":"Post 2 Content","date":"2016-11-09 08:52:09"}, {"id":"17","heading":"Post3","content":"Post 3 Content","date":"2015-06-09 08:52:09"}]
I have over a JSON array. I am trying to convert it to a JSON object as
2016 Nov Post1 Post2 2015 June Post3
I was able to achieve this in PHP using
while ($row = mysqli_fetch_row($result)) { $year = date('Y', strtotime($row['2'])); $month = date('M', strtotime($row['2'])); $navarray[$year][$month][] = array($row[0], $row[1], $row[3]); }
But I can't figure it out in JS.
source share