Forms Symfony2表单日期时间返回错误

Forms Symfony2表单日期时间返回错误,forms,datetime,symfony,Forms,Datetime,Symfony,在我的实体中,我设置了这个 public function setExpiry(\DateTime $expiry = null) { $this->expiry = $expiry; } $builder->add('expiry', 'choice', array( 'choices' => array( date ("Y-m-d H:i:s",mktime(date('H'),date('i'),date('s

在我的实体中,我设置了这个

public function setExpiry(\DateTime $expiry = null)
    {
        $this->expiry = $expiry;
    }
$builder->add('expiry', 'choice', array(
            'choices'   => array(
date ("Y-m-d H:i:s",mktime(date('H'),date('i'),date('s'),date('m'),date('d')
+3,date('Y'))) => '3 days',

            ));
在formType中,我设置了这个

public function setExpiry(\DateTime $expiry = null)
    {
        $this->expiry = $expiry;
    }
$builder->add('expiry', 'choice', array(
            'choices'   => array(
date ("Y-m-d H:i:s",mktime(date('H'),date('i'),date('s'),date('m'),date('d')
+3,date('Y'))) => '3 days',

            ));
但在提交时,返回此错误

::setExpiry() must be an instance of DateTime, string given,
我理解“字符串给定”,但我如何转换为
数据时间对象

像这样的东西怎么样:

new DateTime('@'.strtotime("+3 day")) => '3 days'