How do I format time to hh: mm using Twig (Symfony)

I am extracting a temporary field from an MS SQL database, for example '10: 30: 00 '(hh: mm: ss). I am trying to do this in a branch template, but I want to display only the "10:30" part (hh: mm).

I tried to do this using both number_format and date_format, but I cannot do this. For example, a failed attempt:

<td class="PODTIME">{{ record.PODTIME|number_format(2, ':') }}</td>

Yes, that doesn't make sense. But I can’t find anything even remotely close to what I want — I’m probably missing something.

thank

+4
source share
1 answer

You can use the Twig filter date as follows:

{{ object.date|date('H:i:s') }}

: DateTime Twig

+16

Source: https://habr.com/ru/post/1570448/


All Articles