I have this DateTimeInterface
and I want to set the default value in Symfony6
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $updatedAt = new \DateTimeMutable('now');
However this says New expressions are not supported in this context
How can set the default value for this?
CodePudding user response:
You can use default value in constructor
public function __construct(\DateTimeInterface date = new DateTime("now")) {
$this->updatedAt = date;
}
Have a great day !