Persisting Symfony DateIntervalType in doctrine an

2019-02-28 06:33发布

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.

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

Thanks!

1条回答
时光不老,我们不散
2楼-- · 2019-02-28 07:17

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

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

查看更多
登录 后发表回答