How can I display a formatted date from a Unix timestamp in twig?(如何在 twig 中显示来自 Unix 时间戳的格式化日期?)
问题描述
我想通过对 Unix 时间戳应用过滤器来在 twig 中显示格式化的日期.twig 有这样的功能吗?
I would like to display a formatted date in twig by applying a filter to a Unix timestamp. Is such a feature available in twig?
推荐答案
有一个过滤器叫做 日期
.
在以下示例中,mydate
等于 1286199900
:
In the following example mydate
equals 1286199900
:
{{ mydate|date }} <!-- October 4, 2010 13:45 -->
{{ mydate|date('d/m/Y') }} <!-- 04/10/2010 -->
这篇关于如何在 twig 中显示来自 Unix 时间戳的格式化日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!