在教义中坚持 Symfony DateIntervalType 并将其格式化为 twig
这个问题与 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 ?
谢谢!
推荐答案
doctrine dbal(由doctrine 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
用 twig 显示日期间隔非常简单,只需使用 date
过滤器,该过滤器在内部使用 DateInterval::format
方法.
Display a dateinterval with twig is really easy, just use the date
filter which internally use the DateInterval::format
method.
相关文章