Use Carbon to convert the d-m-Y format date.
Example:
$user->date_column = Carbon::createFromFormat('d-m-Y', $youdate);
$user->save();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi friends!,
I am working in a project with L4 which uses several tables which have date fields.
The problem is that the dates coming to the models are not in the Y-m-d format, i use d-m-Y format in the forms for language reasons.
When i pass the date string coming from the form to a model it crashes.
I have tried to use mutators to format the date as Y-m-d and worked, but it is overwhelming have to create for each model several mutators for the date fields.
Other option i have tried is to create carbon objects from this string dates before passing them to the model, this works, but i have always to do that several times when i want to create or update a model.
Do you know a better way to handle this or any of both i have used is the best?
Thank you!
Please or to participate in this conversation.