简体   繁体   中英

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.

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM