title: How to store MySQL date in Javascript array?
body: <p>I have searched over the Internet, there is a lot of way to store MySQL records into Javascript array though PHP, like <a href="https://stackoverflow.com/questions/21248728/inserting-mysql-results-from-php-into-javascript-array">this one</a>. However I can't really store the date record in Javascript.</p>
  
  <p>Let say,</p>
  
  <p>My MySQL date record rows in column called holiday_date: 2017-06-25, 2017-06-26, 2017-06-27.</p>
  
  <p>How can I store in Javascript after I converted them into json by </p>
  
  <pre><code>&lt;?php
      $sql = "SELECT public_holiday.holiday_date 
              FROM public_holiday";
      $result = mysqli_query($conn, $sql);
  
      $result_array = Array();
  
      while($row = mysqli_fetch_assoc($result))
      {
           $result_array[] = $row;
      }
  
      $json_array = json_encode($result_array);
  
      echo $json_array;
    ?&gt;
  </code></pre>
  
  <p>?</p>
  
  <p>I have tried to store them into a javascript date array like </p>
  
  <pre><code>var holidays = [&lt;?php //sample array for example 
          $loop_one = true;
          foreach ($result_array as $date) 
          {
              if ($loop_one) 
              {
                  echo "'new Date(\'$date\')'";
                  $loop_one=false;
              } 
              else 
              {
                  echo ", 'new Date(\'$date\')'";
              }
          }
  ?&gt;];
  </code></pre>
  
  <p>but all of these are invalid.</p>
  
  <p>I need your help, much appreciated.</p>