Invalid datetime format: 1292 Invalid datetime value - Laravel 5.2
I am getting this error when I insert this 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 set the date or time first?
+4
source to share
6 answers
Since you are not using the standard datetime format, define a mutator for each date. For example:
public function setRegistrationFromAttribute($value)
{
$this->attributes['registration_from'] = Carbon::parse($value);
}
+7
source to share