title: Using json_encode to convert MYSQL datetime to Javascript compatible
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2487921/convert-date-format-yyyy-mm-dd-dd-mm-yyyy">Convert date format yyyy-mm-dd =&gt; dd-mm-yyyy</a>  </p>
  </blockquote>
  
  
  
  <p>I am extracting data from MySQL and passing it to a PHP page, part of which is a <a href="http://almende.github.com/chap-links-library/js/timeline/doc/" rel="nofollow noreferrer">Javascript timeline graph</a>.</p>
  
  <p>I am using json_encode to convert the query result into a format that the Javascript timeline requires.</p>
  
  <p>However json_encode outputs the following:</p>
  
  <pre><code>{"start":"2012-06-06 18:05:21", "content":"Start Date", }
  </code></pre>
  
  <p>Whereas the format the timeline needs is</p>
  
  <pre><code>{"start": new Date(2010,7,23,23,0,0), 'content': "Start Date", }
  </code></pre>
  
  <p>Can I convert the output to the required format either before, or as part of the json_encode process?</p>