title: Date and time from PHP writes 0000-00-00 00:00:00 in MySQL
body: <p>I have a PHP with a JS datepicker for date and time that save all the string in this format "19.08.2012 @ 20:18" in a a variable called $date.</p>
  
  <p>If I place this variable directly in the query, it writes "0000-00-00 00:00:00" in the database.
  At the moment I have a big black hole in my head, so need help.</p>
  
  <p>How can I write the correct selected date and time in the database?</p>
  
  <hr>
  
  <p>Sorry I thought not so important, here is the code.</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function() {
      $("#date").datetimepicker({
          dateFormat:'dd.mm.yy',
          separator: ' @ '
      });
  });
  &lt;/script&gt;
  
  &lt;form action="setting.php" method="post"&gt;
   &lt;table&gt;
   &lt;tr&gt;
    &lt;td&gt;&lt;label for="date"&gt;Date:&lt;/label&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="text" id="date" name="date"/&gt;&lt;/td&gt;
   &lt;/tr&gt;
  &lt;/table&gt;
  &lt;input type="submit" name="submit" /&gt;
  </code></pre>
  
  <p>setting.php</p>
  
  <pre><code>if(isset($_POST['save_autoresp'])) {
      create($_POST['date']);
      header("Location: admin.php");
      exit();
  } else {
      header("Location: index.php");
      exit();
  }
  </code></pre>
  
  <p>functions.php</p>
  
  <pre><code>.......
  .......
  // Write the fields to the table
  $query_create = mysqli_query($link, "INSERT INTO table VALUES (null, '$id', '$date')") or die ('Could not connect: ' . mysqli_error($link));
  .......
  .......
  </code></pre>
  
  <p>The date field in teh MySQL database is "datetime".</p>