title: MySQL JSON_OBJECT() datetime format
body: <p>I'm creating a JSON structure by using a JSON_OBJECT and JSON_ARRAY functions in my select query. The problem I have is with the format in which datetime columns are returned in the formatted JSON result.</p>
  
  <p>For example I have a table <strong>titles</strong></p>
  
  <pre><code>id (INT), title (VARCHAR), created_at (DATETIME)
  </code></pre>
  
  <p>and a row would be like this</p>
  
  <pre><code>1,"Title 1","2019-02-03 12:13:14"
  </code></pre>
  
  <p>If I now do the following query</p>
  
  <pre><code>SELECT JSON_OBJECT('title',title,'created_at',created_at) AS title_json FROM titles WHERE id = 1;
  </code></pre>
  
  <p>I will get the resulting <strong>title_json</strong> column as:</p>
  
  <pre><code>{
      "title": "Title 1",
      "created_at": "2019-02-03 12:13:14.000000"
  }
  </code></pre>
  
  <p>I would like to have the datetime values returned in the standard <strong>YYYY-MM-DD HH:ii:ss</strong> format, without the trailing zeroes.</p>
  
  <p>Is this possible?</p>
  
  <p>I have looked through the JSON_OBJECT documentation but couldn't find any clues to this mystery. I'm thinking the format used might be defined somewhere in the server/database settings. The ideal solution for my case would be to optionally set the desired format in individual queries themselves.</p>
  
  <p>I'm using:
  Server: MySQL Community Server (GPL)
  Version: 5.7.24</p>