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

后端 未结 8 1599
刺人心
刺人心 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
    }
    
    0 讨论(0)
  • 2021-01-25 05:59

    This solved my problem, don't know whether it is the right way to do it or not but i was more concerned about solving it

    if($data['start_date'] != NULL )
    {
    $start_time_array = explode("/", $data['start_date']);
    $start_time = $start_time_array[2]."-".$start_time_array[0]."-".$start_time_array[1]." 00:00:00";
    $model->setStartDate($start_time);
    }
    
    0 讨论(0)
提交回复
热议问题