在原则中保留Symfony DateIntervalType并在树枝中设置其格式 [英] Persisting Symfony DateIntervalType in doctrine and format it in twig

查看:53
本文介绍了在原则中保留Symfony DateIntervalType并在树枝中设置其格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与 DateIntervalType 有关Symfony 3.2中引入的字段类型。该字段允许用户选择表格中的时间间隔。

This question is relative to The DateIntervalType field type introduced in Symfony 3.2. This field allows the user to select an interval of time in a form.

我想知道其对应的教义类型以及如何在枝条中格式化它,例如2小时30分钟?

I would like to know its corresponding doctrine type and how to format it in twig as for example 2 hours and 30 minutes ?

谢谢!

推荐答案

dbal原则(由原则orm)已经支持dateinterval。这里是链接:
http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#dateinterval

The doctrine dbal (which is used by doctrine orm) supports dateinterval already. Here is the link: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#dateinterval

显示带有细枝的dateinterval真的很简单,只需使用 date 过滤器,该过滤器内部使用 DateInterval :: format 方法。

Display a dateinterval with twig is really easy, just use the date filter which internally use the DateInterval::format method.

这篇关于在原则中保留Symfony DateIntervalType并在树枝中设置其格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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