-1

I use Symfony 4.3 and 'bootstrap_4_layout.html.twig' as form theme. How can I setup DateType field to show month numbers instead of month names?

{{ form_widget(formConge.DateBureauOrdre.month, {'var': {'choices': {'label': {'jan': 'a' }} } }) }}
Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
phpsymfony
  • 27
  • 5

2 Answers2

1

If you are using a DateType form field, you have an option there called format which can be used to format the day & month & year fields.

More information can be found on Symfony Documentation

You would better pay attention to deprecation notice:

Deprecated since version 4.3: Using the format option when the html5 option is enabled is deprecated since Symfony 4.3.

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
1

You can use the Twig date format for this purposes, something like the following:

{{ object.date|date('d/m/Y H:i:s') }}

Also, check out this thread: How to render a DateTime object in a Twig template