princeoo7
princeoo7

Reputation: 1121

Incorrect date time value for mysql

I was trying to seed laravel app with faker and their is a column valid_to where I did try to use below code and got the error as following: error:

SQLSTATE[22007]: 
Invalid datetime format: 
1292 Incorrect datetime value: 
'2039-01-16 15:21:43' for column 'valid_to'

code:

 $faker->dateTimeBetween($startDate = 'now', $endDate = '+20 years', $timezone = null),

Issue is, as I changed to +20 years to `+10 years, the code is working. below is the code which worked for me.

 $faker->dateTimeBetween($startDate = 'now', $endDate = '+10 years', $timezone = null),

Is this the limitation for timestamp field in DB (Mysql) ?

Upvotes: 0

Views: 879

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562478

https://dev.mysql.com/doc/refman/8.0/en/datetime.html

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.

You should use DATETIME, not TIMESTAMP.

Upvotes: 1

Related Questions