8

MySQL statement:

insert into `banners` 
    (`path`, `app_id`, `enabled`, `from_date`, `to_date`, `updated_at`, `created_at`) 
values 
    ('banners/example.png', 'com.example.ccp_attacker', 1, '2000-01-01 00:00:00', '2099-12-31 00:00:00', '2100-06-04 00:00:00', '2100-06-04 00:00:00')

generates error #1292 - Incorrect datetime value: '2100-06-04 00:00:00' for column 'updated_at' at row 1

Why 2100-06-04 00:00:00 is not a valid time?

Michael Tsang
  • 678
  • 5
  • 16

1 Answers1

3

MySQL date does not excees 2038. This is a very old problem and for some reason they are not solving it. The max value for acceptable date in MySQL is 2038. When I faced this issue I saved the date in MySQL as varchar and later converted it to date in the business logic.

omar jayed
  • 850
  • 5
  • 16
  • 1
    More information about [the Year 2038 Bug](https://stackoverflow.com/questions/2012589/php-mysql-year-2038-bug-what-is-it-how-to-solve-it). – Cato Minor Feb 07 '22 at 02:49
  • Convert from `TIMESTAMP` to `DATETIME`, see https://stackoverflow.com/questions/24720700/how-convert-field-from-timestamp-to-datetime – sastorsl Jun 29 '22 at 10:47