Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL无效的日期时间格式_Mysql_Yii_Timestamp - Fatal编程技术网

MySQL无效的日期时间格式

MySQL无效的日期时间格式,mysql,yii,timestamp,Mysql,Yii,Timestamp,我在尝试将值2016-03-27T03:15:51.213插入我的Yii1应用程序中数据类型为“timestamp”的列时出现此错误: exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2016-03-27T03:15:51.2

我在尝试将值2016-03-27T03:15:51.213插入我的Yii1应用程序中数据类型为“timestamp”的列时出现此错误:

exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2016-03-27T03:15:51.213' for column 'created' at row 1.
最奇怪的是,当我尝试插入一个2016-03-27T13:15:51.213值时,一切都正常。怎么了


我在Windows机器上使用OpenServer和PHP5.6以及MySql 5.7来执行类似的操作。首先从字符串datetime创建datetime对象

$datetime = date("Y-m-d h:i:s", strtotime("2016-03-27T13:15:51.213"));// Output = 2016.03.27 01:15:51 

然后在sql查询中使用$datetime。

最后我找到了解决方案。问题的原因是在我的Windows计算机上。我有一个主动选项“自动过渡到冬季和夏季”

因此,由于该选项,我的计算机不知道时区变化时凌晨3点到凌晨4点之间的时间,因为当该选项打开时,给定的时间实际上并不存在(如此简单)

当我在电脑上关闭此选项并重新启动电脑时,该消息已从日志中消失

顺便说一句:如果没有自动过渡到冬季和夏季,这个问题不会出现在具有Linux和UTC设置的PC上


希望我的回答能对某些人有所帮助。

你试过2016-03-27T3:15:51.213吗?(3之前没有0)
2016-03-27 03:15:51
用这个试试你的格式很好:2016-03-27T03:15:51.213你可以在那里试试:如果那里有错误并且2016-03-27T13:15:51.213有效,它是从其他地方提交的。你能给我们你试过的表和查询吗?@RealCheeseLord是的,我试过了。同样的错误。@Latsuj抱歉,但这是一个机密信息。我的问题是2016-03-27T03:15:51.213,而不是2016-03-27T13:15:51.213。无论日期如何,该解决方案都有效。为什么要投反对票?你能告诉我吗?