title: How can I store and display a date value in a JavaScript variable from a MySql query in php script?
body: <p>When I insert data (date) in my table and click on the add button it changes it into 0000-00-00 instead of the entered date.
  Please tell me how to store the date into the javascript variable.</p>
  <pre><code>//php code
  &lt;?php
      $edate = mysqli_query($con, $_POST[&quot;edate&quot;]);
      $query = &quot;INSERT INTO expenses(edate, details, spent) VALUES('$edate', '$details','$spent')&quot;;
  ?&gt;
  </code></pre>
  <pre><code>&lt;script&gt;
      $(document).on('click', '#insert', function(){
      var edate = $('#data1').text(); 
  &lt;/script&gt;      
  </code></pre>