Home > Software engineering >  MySQL timestamp throwing incorrect datetime value on one specific datetime
MySQL timestamp throwing incorrect datetime value on one specific datetime

Time:03-05

I have unix timestamps associated with data I am getting from an API. These timestamps are being converted to a datetime via Carbon. I found one specific datetime value that keeps throwing errors:

UPDATE `revive_logs` SET `revivee_last_action_at` = '2018-03-11 02:12:33' WHERE `revive_logs`.`id` = 5129189

Incorrect datetime value: '2018-03-11 02:12:33' for column 'revivee_last_action_at' at row 1

It makes no sense because if I switch the time for 2018-03-11 03:12:33 or 2018-03-11 01:12:33 it works fine. The error happens at that specific date, and hour only. If I change to other hours in that same day MySQL has no problem with it.

What am I doing wrong here? I cannot see anything incorrect about the datetime value. It's a valid date. Even phpMyAdmin lets me set this exact time in their date picker tool and it still throws the error there.

CodePudding user response:

If the timezone is

  • Bermuda
  • Canada
  • Cuba
  • Greenland
  • Haiti
  • Mexico
  • Saint Pierre and Miquelon
  • The Bahamas
  • Turks and Caicos Islands
  • United States

then it is the switch hour between Standard Time and Daylight Saving Time (DST).

On 2018 it was scheduled to Sunday, 11 March 2018 to move clocks from 2 AM to 3 AM.

So there was no time between 02:00:00 and 03:00:00.

Source

  • Related