title: How to insert values from JQuery datepicker to MySQL date datatype using Codeigniter?
body: <p>i can't insert the values from my JQuery Datepicker to my MySQL database with Date datatype. how will i convert string to date datatype? im using Codeigniter with MVC. here's my code:</p>
  
  <p>javascript</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
      $( "#datepicker" ).datepicker({
          showOn: "button",
          buttonImage: "images/icons/calendar_24.png",
          buttonImageOnly: true,
          onSelect: function(dateText, inst){
              $("input[name='dob']").val(dateText);
          }
      });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>function create()
  {
      $data = array(
          'FirstName' =&gt; $this-&gt;input-&gt;post('fname'),
          'DateofBirth' =&gt; $this-&gt;input-&gt;post('dob')
      );
  
      $this-&gt;site_model-&gt;add_record($data);
      $this-&gt;index();
  }
  </code></pre>
  
  <p>view</p>
  
  <pre><code>&lt;?php echo form_open('site/create');?&gt;
  &lt;p&gt;
      &lt;label for="fname"&gt;First Name:&lt;/label&gt;
      &lt;input type="text" name="fname" /&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
      &lt;input type="text" name='dob' id="datepicker" /&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>thanks guys!
  i read some solution in google
  and i did this:</p>
  
  <p>controller:</p>
  
  <pre><code>function create()
  {
      $date = $this-&gt;input-&gt;post('dob');
  
      $data = array(
          'FirstName' =&gt; $this-&gt;input-&gt;post('fname'),
          'DateofBirth' =&gt; date('Y-m-d', strtotime($date))
      );
  
      $this-&gt;site_model-&gt;add_record($data);
      $this-&gt;index();
  }
  </code></pre>
  
  <p>and this solved my problem! :)</p>