Format for time display?

whitebear picture whitebear · Apr 29, 2013 · Viewed 9.3k times · Source

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?

Answer

likeitlikeit picture likeitlikeit · Apr 30, 2013

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.