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

后端 未结 8 1680
刺人心
刺人心 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:57

    $preSaleDate = $_product->getAvailabilityDate();//product attribute
    
    if($preSaleDate) {
      $format = 'Y-m-d H:i:s'; //current format
      $formatted_date = DateTime::createFromFormat($format, $preSaleDate)->format('m/d/Y');
      $dateReal = Mage::app()->getLocale()->date($formatted_date
                                                      ,Zend_Date::DATE_SHORT, null, false);
      $format = 'long'; // short, long, medium, full
      $dueDate = Mage::helper('core')->formatDate($dateReal, $format, false);
    
      echo $dueDate;// will get same day as original $preSaleDate
    }
    

提交回复
热议问题