如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
数据表字段是create_time timestamp 默认:CURRENT_TIMESTAMP
使用时间会出现以下错误:
A non well formed numeric value encountered
这是因为tp5框架会自动转换时间
解决方案如下:
class powerModel extends Model
{
protected $pk = 'id';//主键
//设置当前模型对应的完整数据表名称
protected $table = 'pre_power';
//-------------------
protected $auto = ['create_time'];
public function getCreateTimeAttr($time)
{
return $time;
}
//-------------------
王明昌博客
