3

I am using datepicker in magento form

This is my code:

$dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
        $fieldset->addField('created_at', 'date', array(
        'name'   => 'created_at',
        'label'  => Mage::helper('example)->__('Created At'),
        'title'  => Mage::helper('example')->__('Created At'),
        'image'  => $this->getSkinUrl('images/grid-cal.gif'),
        'format'       => $dateFormatIso,
        'time' => true
    ));

But in frontend same date is not display

enter image description here

At front end

enter image description here

This code is use to display date in frontend

<?php echo $this->formatDate($val->getCreatedAt(), 'medium', true) ;?>
3
  • I'm voting to close this question as off-topic because of question is too old
    – Amit Bera
    Jun 29, 2017 at 7:25
  • Since when is "too old" an off topic reason? Anyways, I'm voting to close because it's unclear. I can only guess that it's about a timezone problem. Jun 29, 2017 at 7:36

1 Answer 1

0

You can try with this one. It worked for me.

Mage::app()->getLocale()->date($val->getCreatedAt(), Zend_Date::DATE_SHORT, null, false);

best of luck.

5
  • this error occured Unable to parse date '2015-03-10 02:52:00' using 'M/d/yy' (M <> y)";i:1;s
    – ND17
    Mar 24, 2015 at 7:16
  • Which region date format you are using? Mar 24, 2015 at 7:18
  • Eastern standard time (America/New_York)
    – ND17
    Mar 24, 2015 at 7:23
  • Please try with this datefromat for admin grid and add/edit block: $dateFormatIso = 'yyyy-MM-dd HH:mm:ss' and frontend use your code. I think it's admin time issue. Mar 24, 2015 at 8:54
  • not working....
    – ND17
    Mar 24, 2015 at 11:05

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