php 向sqlerver datetime类型插入数据

cjqcy416 2017-12-07 05:35:57
用PHP调用WCF后,有一个add方法,参数是对象,向SQL Server插入数据,有一个字段CreateDate类型是datetime,执行就会报错


<?php
$client=new SoapClient("http://192.168.117.223:81/EIPMail.svc?wsdl");
$res = array(
"MailID"=>'BUG00000004',
"Account"=>'353234',
"Address"=>'cjqcy416',
"MailSubject"=>'主题',
"MailBody"=>'正文',
"Url"=>'www.baidu.com',
"SystemName"=>'百度',
"SystemSort"=>'A9',
"Address_BCC"=>'',
"Address_CC"=>'',
"CreateMan"=> 'cjqcy416',
"CreateDate"=> date("Y-m-d H:i:s",time()),
"MailType"=>'通知',
"ID"=>0
);
$info = array('EipMail'=>$res);
$result1 = $client->DoAdd($info);


Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:EipMail. The InnerException message was 'There was an error deserializing the object of type EipMail.Model.EipMailTable. The value '2017-12-07 17:34:04' cannot be parsed as the type 'DateTime'.'. Please see InnerException for more details.
...全文
684 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
A_5120 2018-05-30
  • 打赏
  • 举报
回复
建议不要使用datetime类型,我们一般都用时间戳(unix纪元到现在的秒数)来保存时间,类型就用无符号的int类型即可
cjqcy416 2017-12-11
  • 打赏
  • 举报
回复
看来真的黄了

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧