因为
$newDate是类型的对象
DateTime,而不是字符串。该文档是明确的:
返回
DateTime根据指定格式设置格式的新对象。
如果要从字符串转换
DateTime回字符串以更改格式,请
DateTime::format最后调用以从中获取格式化的字符串
DateTime。
$newDate = DateTime::createFromFormat("l dS F Y", $dateFromDB);$newDate = $newDate->format('d/m/Y'); // for example


