Magento – Grid incorrect Date Issue in admin custom module

admingridmagento-1.9

custom admin grid is showing incorrect date & time .in my database its showing correct also in view detail page its showing correct but in my grid its showing incorrect

Database Date is : 2015-04-10 21:10:54

Grid date is showing incorrect : Apr 10, 2015 4:20:45 PM

I am using the below Code in my grid :

  $this->addColumn('created_date', array(
            'header'    => Mage::helper('mymodule')->__('Date'),
            'align'     => 'left',
            'type'      => 'datetime',
            'index'     => 'created_date',
            'width'     => '150px',
        ));

at the time of save the date i am using the below Code :
'created_date'=>date('Y-m-d H:i:s'),

its showing in database correct but in grid its showing incorrect

Any Help much be appreciated

Best Answer

You can pass the format option to your colum definition. Your column definition should look like

$this->addColumn('created_date', array( 
     'header' => Mage::helper('mymodule')->__('Date'), 
     'align' =>    'left', 
     'type' => 'datetime', 
     'index' => 'created_date', 
     'format' => 'Y-m-d HH:MM:ss' , 
     'width' => '150px'
));

Then the date is displayed correctly in the grid.

Related Topic