Magestore / BannerSlider-Magento

Banner Slider for Magento Community 1.5.x - 1.9.x
http://www.magestore.com/magento-banner-slider-extension.html/
17 stars 11 forks source link

Unable to change date on banners #3

Open xuanbinh92 opened 8 years ago

xuanbinh92 commented 8 years ago

https://magestore.zendesk.com/agent/tickets/10633

Ruby10291 commented 8 years ago

ko tái hiện được

krishana commented 8 years ago

Individual banner Invalid date format selection for start date and end date in admin

For solve this issue need some changes in class Magestore_Bannerslider_Block_Adminhtml_Banner_Edit_Tab_Form

Add function

private function escDates() { return 'yyyy-MM-dd HH:mm:ss';
} and changes in fields

      $fieldset->addField('start_time', 'date', array(
          'label'     => Mage::helper('bannerslider')->__('Start time'),
          'name'      => 'start_time',
          'input_format'  => Varien_Date::DATETIME_INTERNAL_FORMAT,
          'image' => $image_calendar,
          'format'    => $this->escDates(),
          'time' => true,
          'required'  => true,
      ));
      $fieldset->addField('end_time', 'date', array(
          'label'     => Mage::helper('bannerslider')->__('End time'),
          'name'      => 'end_time',
          'input_format'  => Varien_Date::DATETIME_INTERNAL_FORMAT,
          'image' => $image_calendar,
          'format'    => $this->escDates(),
          'time' => true,
          'required'  => true,
          'note'=>$note,
      ));

add $this->escDates() instead of "Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)"

JerichoDiamond commented 8 years ago

This isn't a very solid fix. If magento is set to a non-US time-zone, then the bannerslider controller should switch to a valid dmy separator, i.e. dash or period. Magestore\Bannerslider\controllers\Adminhtml\Bannerslider\BannerController.php Line 130 after opening try { add this block of code

             $tz = Mage::getStoreConfig('general/locale/timezone');
             if(!preg_match('/^america/i',$tz)) {
                 $data['start_time']=str_replace('/','.',$data['start_time']);
                 $data['end_time']=str_replace('/','.',$data['end_time']);
             }
ghost commented 7 years ago

Bump. I'm also experiencing the same issue. The JS date picker outputs in UK format DD/MM/YYYY and saving causes the date to be set to unix epoch (1st January 1970). I'm getting around this by manually typing in a US date (MM/DD/YYYY).

hkvega01 commented 7 years ago

krishana's solution work for me, thanks

vickdoan commented 7 years ago

Lỗi xảy ra khi định dạng format kiểu dd/mm/yyyy

go to this file /app/code/community/Magestore/Bannerslider/controllers/Adminhtml/Bannerslider/BannerController.php - saveAction() funtion

add this codes: $data['start_time'] = str_replace('/', '-', $data['start_time']); $data['end_time'] = str_replace('/', '-', $data['end_time']);

before:

try { $data['start_time']=date('Y-m-d H:i:s',Mage::getModel('core/date')->gmtTimestamp(strtotime($data['start_time']))); $data['end_time']=date('Y-m-d H:i:s',Mage::getModel('core/date')->gmtTimestamp(strtotime($data['end_time']))); } catch (Exception $e) {}