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

MarlonV's avatar

Date submit Error safari

Hello guys,

I'm having a problem with date submitting from a form. It's caused by the way safari os handles the datepicker. I don't know exactly what causing this, so finding a solution is a bit hard if you don't know where to look for.

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '20-02-2012' for column 'birth_date' at row 1 

i have tried to fixed it but with no success.

'birth_date' => Carbon::parse($request->birth_date)->format('Y-m-d'),
0 likes
4 replies
Nakov's avatar

Try this instead:

'birth_date' => Carbon::createFromFormat('d-m-Y', $request->birth_date)->format('Y-m-d'),
MarlonV's avatar

@NAKOV - Thx, will try that. Do i also need to set a default in the input datefield?

<input type="date" class="form-control" value="{{ old('birth_date') }}" name="birth_date">
Nakov's avatar

@MARLONV - Yes, otherwise you might get dates such as 01-01-1970 if null is provided. So you either check if there is a value before the date is set, or set a default one, which will be weird for a birth date to have a default one. I would check if a date is in the request then use this.

TommyShelby's avatar

I had the same issue until I got Gomax TV which has all types of educational and entertainment videos. I hope this helps you solve the problem that you're facing.

Please or to participate in this conversation.