Search code examples
symfonysonata-admin

Format for time display?


I am making application with symfony2 and sonata-admin bundle.

public function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->addIdentifier('id')
        ->add('fromDate');

it shows time like this

September 1, 2013 02:00

so I changed

 -  ->add('fromDate');
 +  ->add('fromDate',null,array('format' => 'yyyy-MM-dd HH:mm:ss'))

but it still show the same.

please give me how to use format for time display?


Solution

  • Try using

    ->add('fromDate','datetime',array('date_format' => 'yyyy-MM-dd HH:mm:ss'))
    

    By the way, the relevant code is here. I think your format option gets overwritten by the system, so it's important to use date_format instead. For an application-wide solution, have a look at this question too.