3
Using Laravel 5.8, I’m using dates.
I can even show the date in the right format, using Carbon
.
Data de Validade {{\Carbon\Carbon::parse($p->dt_validade)->format('d/m/Y') }}
However I can only save by typing with the format YYYY/MM/DD, I wonder how I could save using the standard DD/MM/YYYY. It is possible to do this right on controller
?
Error shown when saving to DD/MM/YYYY format
Invalid datetime format: 1292 Incorrect date value: '10/10/2012' for column 'dt_validity'
Excerpt from the controller where you save the input
$produto->dt_validade = $request->input('dt_validade');
View excerpt:
<div class="col-4">
<label>Data de Validade:</label>
<input type="text" class="form-group" id="dt_validade" name="dt_validade" >
</div>
In short: where can I declare to save in the correct format? Thank you.
Change the input type to
date
and try showing here what the return of the input, please.– Erlon Charles
dt_validity: "2080-12-31". With the input "date" it saves normally, but I need to use type text.
– Fernandes Ferreira