title: converting dd/mm/yyyy into yyyy/mm/dd using php and sql
body: <p>i'm quite new with php. i think this is quite straight forward but i'm confused.</p>
  
  <p>i have a form which asks users for a date of their choice, the format they enter is dd/mm/yyyy</p>
  
  <p>the linked mysql database is formatted yyyy/mm/dd, from what i understand you can't change this.</p>
  
  <p>i'm just trying to figure out where i can change the format of the date. would it be in the sql line that sends the information?</p>
  
  <p>i found this unrelated answer:</p>
  
  <pre><code>&lt;?php 
  $date = date("Y-m-d"); 
  mysql_query("INSERT INTO date_table VALUES ('$name', '$date')", $db_connection); 
  ?&gt;
  </code></pre>
  
  <p>but i can't get this to work...</p>
  
  <p>here are some snippets of the code i currently have:</p>
  
  <pre><code>// Check for night attending:
      if (empty($_POST['night_attending'])) {
          $errors[] = 'You forgot to enter the night you want to attend.';
      } else {
          $na = mysqli_real_escape_string($dbc, trim($_POST['night_attending']));
      }
  </code></pre>
  
  <p>.....................................</p>
  
  <pre><code>// Make the query:
          $q = "INSERT INTO guests (first_name, last_name, email, night_attending) VALUES ('$fn', '$ln', '$e', '$na')";       
          $r = @mysqli_query ($dbc, $q); // Run the query.
          if ($r) { // If it ran OK.
  </code></pre>
  
  <p>.....................................</p>
  
  <pre><code>&lt;p&gt;Night Attending: &lt;input type="text"id="datepicker"  name="night_attending" size="10" value="&lt;?php if (isset($_POST['night_attending'])) echo $_POST['night_attending']; ?&gt;" /&gt;&lt;/p&gt;
  </code></pre>
  
  <p>thanks for your time guys.</p>
  
  <p>alastair</p>