0

当我用奏鸣曲更改数据时间时,它返回错误:

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

这是我的实体:

public function setExpiry($dateAsString = null) {
   $this->expiry = new \DateTime($dateAsString);         
} 

为什么我会收到此错误?

4

1 回答 1

1

像这样更改设置器,因为奏鸣曲使用 DateTime 对象参数调用它

public function setExpiry(\DateTime $datetime){
    $this->expiry = $datetime;
}
于 2012-06-15T15:09:12.203 回答