I am using Doctrine 2.0 with php5.3 , being served from apache2 with a MSSQL\\SQLEXPRESS 2005 backend.
My problem is that when I go to insert a record with a DateTime object, I get the error.
PDOException: SQLSTATE[22007]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting datetime from character string.
As part of troubleshooting, I have verified that the target column is in fact of the type datetime. And I have echoed the query using the EchoLogger which returns something like this
INSERT INTO proposal (proposaldate, ...)
VALUES (?..) { [1]=> object(DateTime)#264 (3) { ["date"]=> string(19) "2010-11-20 22:15:12" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "America/New_York" }..}
The most disconcerting thing is that a similar class using the same packages executes flawlessly when inserting the datetime in the same manner.
Any help is greatly appreciated.
Sounds like a locale issue. To overcome, write your strings out in ISO 8601 format, ie. YYYYMMDD
2010/21/11
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.