我怎样才能显示一个格式化的日期从一个Unix时间戳树枝? [英] How can I display a formatted date from a Unix timestamp in twig?

查看:150
本文介绍了我怎样才能显示一个格式化的日期从一个Unix时间戳树枝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过对Unix时间戳应用一个过滤器来显示一个格式化的日期。有这样一个功能可以在树枝?

解决方案

有一个过滤器称为 date 。 b

在以下示例中, mydate 等于 1286199900

  {{mydate | date}}<! -  2010年10月4日13:45  - > 
{{mydate | date('d / m / Y')}}<! - 04/10/2010 - >


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?

解决方案

There is a filter called date.

In the following example mydate equals 1286199900:

{{ mydate|date }}           <!-- October 4, 2010 13:45 -->
{{ mydate|date('d/m/Y') }}  <!-- 04/10/2010 -->

这篇关于我怎样才能显示一个格式化的日期从一个Unix时间戳树枝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆