【发布时间】:2023-01-17 23:10:05
【问题描述】:
我想将 Y-m-d 日期格式保存为字段日期
#[ORM\Column]
private ?\DateTimeImmutable $created_at = null;
当我保存这个格式化日期时:
$date = new DateTimeImmutable();
$date->setTimestamp($timestamp);
$date->format("Y-m-d");
Symfony 使用以下格式保存:
2023-01-17 14:34:55
当我尝试像这样保存日期时:
$date = date("Y-m-d", $timestamp);
我得到一个错误:
must be of type DateTimeImmutable, string given
我错过了什么?
【问题讨论】: