Search code examples
phpsymfonysonata-admindatetime-formatsymfony-3.2

Symfony Sonata - How to show minutes format for datetime in listMapper?


I'm usinf Symfony 3.2.9 with Sonata-admin bundle.

I've create this field in my Entity component:

    /**
 * @var \DateTime $verificat
 *
 * @ORM\Column(type="datetime", nullable=true)
 */
private $verificat;

In his admin class there is this function:

protected function configureListFields(ListMapper $listMapper)
{

    $listMapper->add('verificat','datetime',array('label' => 'Data verificació','format' => 'd/M/Y H:mm'));
}

My problem is that it transforms the date like 2017/Jun/12 13:0606. Where I want to show minutes it shows the month number in the year.

I'd like to know how to show minuts, and even better, how to build any pattern format.


Solution

  • Try looking what the format literals actually mean and how the date_format function works:

    http://php.net/manual/en/function.date.php

    m stands for month while i stands for minutes.

    Try

    'd/m/Y H:i'