Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL Invalid date exception #438

Open
koenpunt opened this issue Jul 19, 2014 · 4 comments
Open

MySQL Invalid date exception #438

koenpunt opened this issue Jul 19, 2014 · 4 comments

Comments

@koenpunt
Copy link
Collaborator

Depending on your MySQL configuration, errors like this can appear:

PDOException' with message 'SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2014-07-19 09:59:36 UTC' for column 'updated_at' at row 1

The error does make sense, because MySQL does not know about timezone (UTC part).

So I tried to find where it does add the timezone, but yet without success.

This error can be suppressed, (or ignored?) by removing STRICT_TRANS_TABLES from the sql_mode: http://dev.mysql.com/doc/refman/5.1/en/sql-mode.html#sqlmode_strict_trans_tables

@willpower232
Copy link

Just poking my nose in but isn't this similar to #412 ?

@tuupola
Copy link
Contributor

tuupola commented Aug 6, 2014

You can also start mysql server with --sql-mode=ALLOW_INVALID_DATES switch.

@andyleap
Copy link

andyleap commented Dec 8, 2014

more disturbingly, this is what I pushed #317 over a year ago to fix, but it still hasn't gotten merged. koenpunt is apparently starting to work on it now.

@rkyoku
Copy link

rkyoku commented Feb 3, 2018

@andyleap I think he hasn't :)

Why not just setting \ActiveRecord\Connection::$datetime_format = 'Y-m-d H:i:s'; prior to creating the connection?

It seems to fix the issue for me (after migrating from PHP 5.6 to PHP 7 and from MySQL 5.6 to MySQL 5.7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants