Reputation: 21
Upon Registration on my laravel website, I can happly register fine however whenever someone's birthday appears to be an older date before 1970 it will always throw an error like this
Illuminate \ Database \ QueryException (22007) SQLSTATE[22007]:
Invalid datetime format: 1292 Incorrect datetime value: '1963-07-17' for column
cp644657_portal
.users
.date_of_birth
at row 1 (SQL: insert intousers
(name
,address_line_1
,suburb
,state
,post_code
,date_of_birth
,mobile
,position
,password
,updated_at
,created_at
) values (Test Tesy, [email protected], Test, Test, Test, 4151, 1963-07-17, 0400000000, , $2y$10$H4Ey15q0XqunxuLmziE01OhR3jTEBIHzNJZscA85mQdf88nrYDgEa, 2019-07-16 23:11:07, 2019-07-16 23:11:07))
Previous exceptions
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '1963-07-17' for column
cp644657_portal
.users
.date_of_birth
at row 1 (22007)
Upvotes: 1
Views: 677
Reputation: 5149
It sounds like you are trying to store the data in a TIMESTAMP column. You will need to change it to DATE or DATETIME for dates before 1970.
https://dev.mysql.com/doc/refman/5.5/en/datetime.html
The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.
The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD hh:mm:ss' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.
Upvotes: 1