我有这个DateTimeInterface,我想在Symfony6中设置默认值
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $updatedAt = new \DateTimeMutable('now');然而,这表示New expressions are not supported in this context
如何为此设置默认值?
发布于 2022-08-30 10:25:10
可以在构造函数中使用默认值。
public function __construct(\DateTimeInterface date = new DateTime("now")) {
$this->updatedAt = date;
}祝你今天愉快!
https://stackoverflow.com/questions/73529700
复制相似问题