I have created a field in custom admin form with following code
$fieldset->addField('post_date', 'date', array(
'label' => Mage::helper('sprung_blog')->__('Date'),
'name' => 'post_date',
'required' => true,
'class' => 'required-entry',
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
));
But its only saving the date i have selected.How can i get the time too.
In my saveAction i have following too
$data = $this->_filterDates($data, array('post_date'));
I have tried by changing it to
$fieldset->addField('post_date', 'date', array(
'label' => Mage::helper('sprung_blog')->__('Date'),
'name' => 'post_date',
'required' => true,
'class' => 'required-entry',
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'time' => true,
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
));
Now i can see time in field.But in controller it comes as [post_date] => 2014-07-24
Best Answer
You have to run
$productData = $this->_filterDates($productData, $dateFields);
for dates and_filterDateTime
for datetime values on them. To make a mysql-readable format out of them, before saving