FOSCommentBundle 中的日期格式

Dateformat in FOSCommentBundle

我在我的 Symfony 3 项目上使用 FOSCommentBundle,一切正常。但我想更改日期格式。我的日期显示是这样的

August 11, 2017 15:27

我要:

11 August 2017

在 config.yml 中,我的参数设置为法语,但没有任何变化。

此路径中包含“$createdAT”的实体:

FriendsOfSymfony/FOSCommentBundle/blob/master/Model/Comment.php

要更改格式,您应该从该路径中的树枝更改它:

FOSCommentBundle/Resources/views/Thread/comment_content.html.twig

因此您更改此行以获得所需的格式:

{{  comment.createdAt|date("d/m/Y", false) }}

如果您想了解更多有关 twig 中日期格式的信息,请查看此 link:

https://twig.symfony.com/doc/2.x/filters/date.html

我认为这不是很好的解决方案:

{{ comment.createdAt|date("d/m/Y", false) }}

当您在 vendor 中刷新库时,您将丢失更改。更好的方法是像这样在配置中更改它:

# Twig Configuration twig: date: format: d/m/Y