dtxooq1020 2018-05-22 19:12
浏览 74

MySql datetime:在DateTime :: DATE_ATOM中抛出日期错误

I got MySql 5.7 DB on hosting. DB contains table with datetime column. for example:

CREATE TABLE test_date (
  `date` datetime NOT NULL
)

There is some date in PHP application which we should store into datetime column. To achieve that date is formatted using DateTime::DATE_ATOM format. PHP application is inserting record into that table using some framework (this is not important) so finally INSERT query is looking as the following:

INSERT INTO `test_date`(`date`) VALUES ('2018-05-22T12:33:16-03:00')

but MySql is throwing an error:

#1292 - Incorrect datetime value: '2018-05-22T12:33:16-03:00' for column 'date' at row 1

if I remove time zone offset from string (-03:00) insert is completed successfully.

I have multiple instances of MySql 5.6 installed on local VM and on different remote data centers but I never faced this issue: MySql always worked correctly with datetime formatted using DateTime::DATE_ATOM.

I digged Google but didn't find any specific changes in MySql 5.7 related to datetime.

Can you please point me why DateTime::DATE_ATOM string is rejected by MySql 5.7 or provide any pointers?

Update: looks like root cause of this issue is missed NO_ENGINE_SUBSTITUTION sqlMode (ref MYSQL incorrect DATETIME format). Looks like it is set by default on most of installations (or admins are setting it) but not on my hosting.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题