Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mateog98's avatar

Why am i getting a format date error?

Im inserting data and storing it through a form, but when i submit it i get the following error:

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '11-11-2021' for column `axis`.`tickets`.`entry` at row 1

This is my entry date field:

<div class="form-group col-md-2">
        <label for="entry">Fecha de Ingreso a Laboratorio</label> 
         <input type="text" name="entry" id="entry" class="form-control form-control-sm" placeholder="Fecha De Ingreso" required readonly>
  </div>

This is my jquery datepicker:

 $('#entry').datepicker({
    uiLibrary: 'bootstrap4',
    format: 'dd-mm-yyyy'
    
});

This is the part of my store method which involves this field:

 $ticket->entry = $request->entry;

And this is how im declaring this column in my migration:

 $table->date('entry');

Why am i getting this format error?

0 likes
2 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Because you need year first.. Year, month, day

$ticket->entry = Carbon:createFromFormat ('d-m-Y', $request->entry)->toDateString();
1 like

Please or to participate in this conversation.