Skip to content
Advertisement

Invalid datetime format: 1292 Incorrect datetime value – Laravel 5.2

I’m getting this error when I insert these value into my database table:

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value:
'24/06/2017' for column 'registration_from' at row 1 
(SQL: insert into `campus_registrations` (`campus_major_class_id`, 
`registration_from`, `registration_to`, `testing`, `announcement`, 
`enrollment_from`, `enrollment_to`, `updated_at`, `created_at`) values (3, 
24/06/2017, 27/06/2017, 13/07/2017, 01/08/2017, 05/09/2017, 31/01/2018,
 2017-06-07 09:39:31, 2017-06-07 09:39:31))

Do I have to intiate the datetime first or what?

Advertisement

Answer

The error is here:

Incorrect datetime value: '24/06/2017' for column 'registration_from' at row 1

the default format for date column in mysql is Y-m-d and for datetime is Y-m-d H:i:s. So change your date to this format and try again.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement