Persisting Symfony DateIntervalType in doctrine and format it in twig(在教义中坚持 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.
这篇关于在教义中坚持 Symfony DateIntervalType 并将其格式化为 twig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在教义中坚持 Symfony DateIntervalType 并将其格式化为 twig
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- Laravel 仓库 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01