2017-08-11 42 views
0

我在我的Symfony 3項目上使用FOSCommentBundle,一切正常。但我想更改日期格式。我的日期顯示是這樣FOSCommentBundle中的Dateformat

2017年8月11日15:27

我想:

2017年8月11日

在config.yml,我的參數是設置爲法語但沒有改變。

+0

請向我們提供您如何更改日期。問候 – Albeis

+0

@Albeis你可以看看我的答案有一個鏈接,可以幫助你。提示 –

+0

謝謝,但不適合我,這是爲@Simon問候 – Albeis

回答

1

包含 '$ createdAT' 在這個路徑中的實體:

FriendsOfSymfony/FOSCommentBundle/BLOB /主/型號/ Comment.php

,並更改格式,你應該從樹枝改變在這條道路:

FOSCommentBundle /資源/視圖/主題/ comment_content.html.twig

所以你改變這一行來得到你想要的格式:

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

檢查這個環節如果u想知道更多關於日期格式樹枝:

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

0

我不認爲如果它很好的解決方案:

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

在刷新庫在供應商中,你會失去你的改變。更好的方法是改變它在配置這樣的:

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