Magento custom module date field saving date to one day before the selected date

后端 未结 8 1667
刺人心
刺人心 2021-01-25 05:08

i followed steps on this link to add a date field to my custom module :

http://magentomechanic.blogspot.com/2010/01/to-add-custom-date-field-in-custom.html

Every

8条回答
  •  星月不相逢
    2021-01-25 05:42

    Be sure, when you save date you do some like this

    $dt = $this->getResource()->formatDate(time());
    $this->setData('created_at', $dt); // current model
    

    Then for getting correct timezone date use some like this

    $dt = $this->getData('created_at');
    $time = $this->_getResource()->mktime($dt);
    if ($time) {
        $dt = Mage::app()->getLocale()->date($time, null, null, true);
    }
    

提交回复
热议问题