1

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

3

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

  • Already i have added it.But only its showing date that i selected.Time is saved as 00:00 – Ann Mary Jul 1 '14 at 8:33
  • Please check my updated question – Ann Mary Jul 1 '14 at 8:49
  • You did all the normal stuff, like cleaning the cache, right? :-) – Fabian Blechschmidt Jul 1 '14 at 9:02
  • Yes..I can select time and its there on field.But when i print it in saveAction() it shows only date. Time value is not coming. – Ann Mary Jul 1 '14 at 9:04
  • sorry, you have to use _filterDateTime, updated the answer – Fabian Blechschmidt Jul 1 '14 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.