title: PHP: Inserting date into a table
body: <p>My table "list" contains one field: "exam_date" of type "datetime".
  Dates in that table are formatted by the following structure: "2014-08-31 21:45:47" (yyyy-mm-dd hh:ii:ss).
  In my input form date is assigned the following way:</p>
  
  <pre><code>&lt;input id="exam_date" name="exam_date" type="datetime" placeholder="&lt;?php echo date('d-m-y H:i:s'); ?&gt;"&gt;
  </code></pre>
  
  <p>In order to see the value assigne i added to my code:</p>
  
  <pre><code>$myDate = trim($_POST['exam_date']);
  echo trim($_POST['exam_date']);
  </code></pre>
  
  <p>On the display i see the date inserted by the following structure:31-08-14 21:45:47.
  My code to insert the new value to the table is:</p>
  
  <pre><code>&lt;?php
  date_default_timezone_set('xxx');
  $dbcon = @mysqli_connect ('xxx', 'xxx', 'xxx', 'test') OR die ('Could not connect to MySQL: ' . mysqli_connect_error () ); 
  mysqli_set_charset($dbcon, 'utf8');
  if (isset($_POST['exam_date']))
  {
   $myDate = trim($_POST['exam_date']);
   echo $myDate ;
   $q = "INSERT INTO list (exam_date) VALUES ($myDate)"; 
   $result = @mysqli_query ($dbcon, $q); 
   if($result)
   {
     echo "record added";
   }
   else
   {
     echo "no record added !";
   }
  }
  ?&gt;
  &lt;form action="add_date.php" method="post"&gt;
  &lt;input id="exam_date" name="exam_date" type="datetime" placeholder="&lt;?php echo date('y-m-d H:i:s'); ?&gt;"&gt;
  &lt;input id="submit" type="submit" name="submit" value="Register"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When I run it i get: "no record added" and when I check the table I see that no record was added indeed.
  I belive that the reason for not able to add a record is the difference in date structures: that of the table and that of the input.
  Can I change the date structure in the table to "dd-mm-yy hh:ii:ss"? 
  Is there a way to convert the input structure from "dd-mm-yy hh-ii-ss" to "yyyy-mm-dd hh:ii:ss"?
  Thanks !</p>