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

Chiranjeevi's avatar

Date error while form submit

I'm facing problem with date value to store in the database, it's all working all fine if I select a date in datepicker http://eonasdan.github.io/bootstrap-datetimepicker , but when I skip this date (not selected) it's showing error

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '' for column 'date_of_birth' at row 1 (SQL: insert into `users` (`email`, `first_name`, `last_name`, `date_of_birth`, `bio`, `gender`, `country`, `state`, `city`, `address`, `postal`, `password`, `updated_at`, `created_at`) values ([email protected], Anika, Byrd, , afdf, male, , , , , , $2y$10$njWaF8MaUxNY76nYJ7KGo.ml4adCS/Oxy9EVgM.mepZ0jJbRDWEu2, 2016-09-13 09:47:59, 2016-09-13 09:47:59))

I've set this field as date type and nullable in migration , $table->date('date_of_birth')->nullable(); I didn't face this type of error in laravel5.1 and 5.2. Now I'm using Laravel5.3 and I don't find any changes in migration of laravel5.3. please help me in this.

0 likes
1 reply

Please or to participate in this conversation.