symfony 1.4和doctrine 1.2中的短时间戳

时间:2011-06-06 18:36:20

标签: php symfony1 doctrine symfony-1.4

我在Symfony中生成了新项目,我使用了Doctrine:

expires_at:   { type: timestamp, notnull: true }

但对我来说太长了。我只需要2011/06/05。我怎样才能做到这一点?表单中的小部件要求太多。还必须填写例如毫秒。

此:

unset(
  $this['expires_at']
);

删除了小部件中的所有字段。我希望像2011/06/05这样的东西。

1 个答案:

答案 0 :(得分:1)

doctrine具有用于此目的的特殊数据类型:http://www.doctrine-project.org/documentation/manual/1_2/pl/defining-models:columns:data-types#date

将它放在schema.yml:

expires_at:   { type: date, notnull: true }

并重新生成表单。