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

AucT's avatar
Level 2

Next Illuminate\Database\QueryException: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '1980-00-00'

Hi! when I try to update date from laravel with Eloquent model it shows error. But when I do this in phpmyadmin everything works fine.

p.s. I have mysql 5.7 with settings that allow zero date and zero in dates

please halp!

0 likes
10 replies
rcubitto's avatar

Can you provide the snippet that generates this error?

jlrdw's avatar

Are you using a date or timestamp?

AucT's avatar
Level 2

I'm using date

Illuminate\Support\Facades\DB::table('persons')->where('id',22)->update(['birthday'=>'1980-00-00']);

Snapey's avatar

Why do you think 1980-00-00 should be accepted by the database?

1 like
AucT's avatar
Level 2

because I need it and it's working fine, but not in laravel.

if so do you think using 3 separate int columns is good (year, month, day)?

MWDeveloper's avatar

save it like this "1980-00-00 00:00 " and when you want to retrieve it from the database then you can ignore the time

Snapey's avatar

still don't understand why you want to save 1980-00-00

1 like
AucT's avatar
Level 2

there are 3 scenarious

  1. person has only year of birth
  2. person has only month and day of birth
  3. person has full date
tykus's avatar
tykus
Best Answer
Level 104

I agree with @Snapey, but if you want to store the information as you describe, then create separate the year, month and day into their own columns.

1 like

Please or to participate in this conversation.