title: How to return JSON response in below format from MySQL table in PHP
body: <p>In my Database table I store dates in a format like this <strong>2015-03-22</strong> in a date column. </p>
  
  <pre><code>|   mydate   |
  ------------
  | 2015-03-22 |
  | 2015-03-17 |
  | 2015-04-02 |
  | 2015-04-01 |
  </code></pre>
  
  <p>I need <code>JSON</code> to return a response like: </p>
  
  <pre><code>    {  
     "result": [{    
       "2014":[{}],
       "2015":[{
          "April":[
              "2015-04-05",
              "2015-04-04",
              "2015-04-03",
              "2015-04-01"
          ],
          "March":[
              "2015-03-25",
              "2015-03-14",
              "2015-03-07",
              "2015-03-01"
          ]
       }] 
     }]    
  }
  </code></pre>
  
  <p>I tried this query, but I failed to make JSON objects like above:</p>
  
  <pre><code>$getDate = "SELECT DISTINCT( mydate), MONTHNAME( mydate ) AS m, YEAR( mydate ) as y 
  FROM table_name 
  GROUP BY m, mydate  ORDER BY mydate DESC";
  </code></pre>