laravel - Laravel:无效的日期时间格式:1292 不正确的日期时间值:'2021-03-14 02:00:00'
问题描述
我收到很多无效的日期时间格式错误
[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]
错误开始于:2021-03-14 02:00:00
结束于:2021-03-14 02:58:46
一年多来一切正常
一切恢复正常,无需任何代码更改。
有人可以帮助我了解发生了什么吗?
配置/app.php:
- '时区' => '非洲/突尼斯',
表结构:
- 服务器:通过 UNIX 套接字的 localhost
- 服务器类型:MariaDB
- 服务器连接:未使用 SSL 文档
- 服务器版本:10.3.27-MariaDB-log-cll-lve - MariaDB 服务器
- 协议版本:10
- 用户:xxx@localhost
- 服务器字符集:cp1252 西欧 (latin1)
解决方案
问题是因为夏令时 (DST)。
您的应用设置为“Africa/Tunis”,我认为它无法识别 DST。但这是数据库错误,而不是应用程序错误。您的数据库显然正在使用识别 DST 的时区。
DST 于 2021 年 3 月 14 日 02:00:00 开始。因此,2021-03-14 02:00:00 和 2021-03-14 02:59:59 之间的时间不存在,并且不是有效时间,从而导致您收到错误。
推荐阅读
- python - 求解带阶跃函数的微分方程
- jquery - div 在从顶部以设置的像素数滚动后变为固定,也仅大于设置的窗口宽度,并添加了边框底部
- qnx - 致命:使用 mkxfs 的文件系统溢出错误
- php - 来自变量的Wordpress过滤器?
- python-3.x - 如何显示相距 15 分钟的记录的频率
- azure-devops - VSTS Publish Artifact 为空,MVC Web 应用程序在本地部署
- python - 在 Pandas Dataframe 列中的嵌套字典中搜索和替换
- python - 如何通过用 Python 编写的 CGI 脚本执行 bash 脚本?
- reactjs - ScrollView 不会使用 scrollTo() 水平移动
- jquery - 从超链接渲染局部视图