我收到很多无效的日期时间格式错误
[2021-03-14 02:00:00] production.ERROR: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2021-03-14 02:00:00' for column `xxxxxxx`.`users`.`last_activity` at row 1 (SQL: update `users` set `last_activity` = 2021-03-14 02:00:00, `users`.`updated_at` = 2021-03-14 02:00:00 where `id` = 2561) {"userId":2561,"exception":"[object] (Illuminate\\Database\\QueryException(code: 22007): SQLSTATE[22007]:
[stacktrace]
[2021-03-14 02:58:46] production.ERROR: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2021-03-14 02:58:46' for column `xxxx`.`posts`.`updated_at` at row 1 (SQL: update `posts` set `view` = `view` + 1, `posts`.`updated_at` = 2021-03-14 02:58:46 where `id` = 43018) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 22007): SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2021-03-14 02:58:46' for column `xxxx`.`posts`.`updated_at` at row 1 (SQL: update `posts` set `view` = `view` + 1, `posts`.`updated_at` = 2021-03-14 02:58:46 where `id` = 43018) at /home/xxxx/xxxxx/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 22007): SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2021-03-14 02:58:46' for column `xxxx`.`posts`.`updated_at` at row 1 at /home/xxxx/xxxx/vendor/laravel/framework/src/Illuminate/Database/Connection.php:483)
[stacktrace]
Run Code Online (Sandbox Code Playgroud)
错误开始于:2021-03-14 02:00:00
结束于: 2021-03-14 02:58:46
一年多以来一切正常
一切都恢复正常,无需更改任何代码。
有人可以帮助我了解发生了什么事吗?
配置/app.php:
表结构:
该问题是由于夏令时 (DST) 造成的。
您的应用程序设置为“非洲/突尼斯”,我认为它无法识别夏令时。但这是数据库错误,而不是应用程序错误。您的数据库显然正在使用可识别 DST 的时区。
夏令时于 2021 年 3 月 14 日 02:00:00 开始。因此,2021-03-14 02:00:00 和 2021-03-14 02:59:59 之间的时间不存在,并且不是有效时间,从而导致您收到错误。