模型中$autoWriteTimestamp = true设置后,用getDate方法时间不格式化

浏览:4772 发布日期:2017/10/03 分类:ThinkPHP5专区 关键字: 时间戳
模型时间戳存在如下问题protected $autoWriteTimestamp = true;  
 protected $createTime = 'add_time';
-----
//方法中用getData,输出后时间没自动格式化
$add_time=$this->getData('add_time');
// 无奈用这种方式就可以
$add_time=$this->add_time;
手册中明确有“如果你是在模型内部,请不要使用$this->name的方式来获取数据,请使用$this->getAttr('name') 替代”
这个的词句来强调“$add_time=$this->add_time;”这种方式的不可取!
不知如何是好啊
最佳答案
评论() 相关
后面还有条评论,点击查看>>