title: Save date to MySQL format by using Laravel Carbon
body: <p>Trying to convert JQuery Datepicker date format 'dd-mm-yy' to MySQL date format 'YYYY-MM-DD' before saving to database using Carbon.</p>
  
  <p>I have tried using Carbon in store method before inserting data but still no luck, it saves date as '0000-00-00'.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="text" name="reg_date" id="regdate" value="{{ old('reg_date', date('d/m/Y')) }}"&gt;
  </code></pre>
  
  <p>JQuery:</p>
  
  <pre><code>&lt;script&gt;
    $(function(){
      $("#regdate").datepicker({
      dateFormat: 'dd-mm-yy',
      changeMonth: true,
      changeYear: true,
      showAnim: 'slideDown'
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>use Carbon\Carbon;
  
   public function store(Request $request)
      {
          $data = $request-&gt;validate([
              'reg_date' =&gt; 'required',
              'first_name' =&gt; 'required|alpha',
              'last_name' =&gt; 'required|alpha',
          ]);
  
          $object = new ModelName();
          $regdate = 'reg_date';
          $object-&gt;date = \Carbon::createFromFormat('d-m-Y', $regdate)-&gt;format('Y-m-d');
  
          ModelName::create($data); // create() method to insert data to database.
      }
  </code></pre>
  
  <p>Date should save in 'YYYY-MM-DD' format to database.</p>
  
  <pre><code>PS: Data type is 'DATE'.
  </code></pre>