您现在的位置是:首页 > ThinkPHP

李清波 2020-03-29 ThinkPHP 1538 复制当前网址

DateTime::__construct() expects parameter 1 to be string, int given

报错:DateTime::__construct() expects parameter 1 to be string, int given

Thinkphp6.0的框架的情况下

->toArray();
return json(['code'=>0,'msg'=>'success','data'=>$data]);

只要对象转化为数组,都会报错,这里主要是涉及到时间格式的原因
Thinkphp6解决办法

方法一:(推荐)

找到配置文件database.php

找到

'auto_timestamp'  => true,

改成

'auto_timestamp'  => false,

方法二:

到当前模型下,加入以下代码

protected $autoWriteTimestamp = false;

微信截图_20200329214208.png

文章来源:https://www.liqingbo.com/blog-1677.html

评论