title: Laravel: Converting m/d/Y to Y-m-d from jQuery UI Datepicker before saving to database
body: <p>I am trying to save a date from jQuery UI datepicker to database.</p>
  <p>I want to display the date in m/d/Y format on date selection from the input form.</p>
  <p>When I try to save it to the database, it is giving the following error:
  <strong>SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value</strong></p>
  <p>I have followed a lot of solutions, however it is not working for me.</p>
  <p>I have looked through this <a href="https://laraveldaily.com/how-to-change-date-format-in-laravel-and-jquery-ui-datepicker/" rel="nofollow noreferrer">link</a>, though I followed everything correctly, it is still returning the same error.</p>
  <p><strong>Controller Code</strong></p>
  <pre><code>    public function store(Request $request)
      {
          $user = Frontend::create($request-&gt;all());
      }
  </code></pre>
  <p><strong>Model Code</strong></p>
  <pre><code>class Frontend extends Model
  {
      use HasFactory;
  
      protected $table = 'frontend';
  
      protected $fillable = ['date'];
  
      public function setDateAtttribute($date)
      {
          $this-&gt;attributes['date'] = Carbon::createFromFormat($date)-&gt;format('Y-m-d');
      }
  }
  </code></pre>
  <p><strong>config&gt;app.php</strong></p>
  <pre><code>'date_format' =&gt; 'm/d/Y',
  'date_format_javascript' =&gt; 'mm/dd/yy',
  </code></pre>
  <p>I am new to this and it would be a huge help if anyone could help me find the solution.</p>