title: Converting date format from d-m-Y to Y-m-d
body: <p>As you know, date format from a database is Y-m-d, I need to echo the date in d-m-Y.
  This is the code for echo:</p>
  
  <pre><code>    &lt;td class="pk"&gt;From&lt;/td&gt;
            &lt;td width="50%" class="pk_2"&gt;&lt;input name="personal_ic_from" type="text" class="tcal" id="personal_ic_from" value="&lt;?php
  echo date_create($personal_ic_from)-&gt;format('d-m-Y');
  ?&gt;" readonly="readonly"/&gt;
            &lt;/td&gt;
  </code></pre>
  
  <p>My problem is, after the user changes the date of <code>personal_ic_from</code>, I need to convert back the date format from d-m-Y to Y-m-d (which is the standard format for date in database) in update query. However, I can't manage to do that..</p>
  
  <p>This my update query:</p>
  
  <pre><code>&lt;?php
  $personal_ic_from = $_POST['personal_ic_from'];
  $personal_ic_to  = $_POST['personal_ic_to'];
  $personal_ic_num = $_POST['personal_ic_num'];
  $personal_ic_old_num = $_POST['personal_ic_old_num'];
  $personal_ic_issuing_autho = $_POST['personal_ic_issuing_autho'];
  $personal_ic_issuing_num = $_POST['personal_ic_issuing_num'];
  $personal_ic_issuing_date = $_POST['personal_ic_issuing_date'];
  $personal_ic_date_expiry = $_POST['personal_ic_date_expiry'];
  $personal_ic_place_issue = $_POST['personal_ic_place_issue'];
  $personal_ic_country_issue = $_POST['personal_ic_country_issue'];
  $personal_ic_country = $_POST['personal_ic_country'];
  
  
  mysql_query("UPDATE personal_id_ic SET personal_ic_from = '".mysql_real_escape_string($_POST["personal_ic_from"])."', personal_ic_to = '".mysql_real_escape_string($_POST["personal_ic_to"])."', personal_ic_num = '".mysql_real_escape_string($_POST["personal_ic_num"])."', personal_ic_old_num = '".mysql_real_escape_string($_POST["personal_ic_old_num"])."', personal_ic_issuing_autho = '".mysql_real_escape_string($_POST["personal_ic_issuing_autho"])."', personal_ic_issuing_num = '".mysql_real_escape_string($_POST["personal_ic_issuing_num"])."', personal_ic_issuing_date = '".mysql_real_escape_string($_POST["personal_ic_issuing_date"])."', personal_ic_date_expiry = '".mysql_real_escape_string($_POST["personal_ic_date_expiry"])."', personal_ic_place_issue = '".mysql_real_escape_string($_POST["personal_ic_place_issue"])."', personal_ic_country_issue = '".mysql_real_escape_string($_POST["personal_ic_country_issue"])."', personal_ic_country = '".mysql_real_escape_string($_POST["personal_ic_country"])."' WHERE LAS_login_id = '".mysql_real_escape_string($_POST["LAS_login_id"])."'");
  
  ?&gt;
  </code></pre>
  
  <p>How can I convert back the format from d-m-Y to Y-m-d so database can save the new date?
  I tried to change the query to for <code>personal_id_ic</code> , but when I use this code the database saved a random date, not the date that user choose:</p>
  
  <pre><code>mysql_query("UPDATE personal_id_ic SET personal_ic_from = '".mysql_real_escape_string($_POST["personal_ic_from, %Y-%m-%d"])."' WHERE LAS_login_id = '".mysql_real_escape_string($_POST["LAS_login_id"])."'");
  </code></pre>