Dim*_*ero 1 php datepicker magento
我正在使用magento 1.7.2,我想添加日期属性和时间,这样可以保存日期以及数据库中该产品的时间.
我试过这个代码在我的模块中使用mysql-setup文件添加新属性.
$setup->addAttribute('catalog_product', 'new_date', array(
'group' => 'General',
'input' => 'date',
'type' => 'datetime',
'label' => 'New Date',
'backend' => 'eav/entity_attribute_backend_datetime',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'searchable' => 1,
'filterable' => 1,
'comparable' => 1,
'visible_on_front' => 1,
'visible_in_advanced_search' => 0,
'is_html_allowed_on_front' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
Run Code Online (Sandbox Code Playgroud)
但这只给我选择时间的日期.
请帮我.
谢谢.
尝试使用后端(任何管理面板表单):
$fieldset->addField('your_column_name', 'date',array(
'name' => 'image_link', /* should match with your table column name where the data should be inserted */
'time' => true,
'class' => 'required-entry',
'required' => true,
'format' => $this->escDates(),
'label' => Mage::helper('featuredpopup')->__('From:'),
'image' => $this->getSkinUrl('images/grid-cal.gif')
));
Run Code Online (Sandbox Code Playgroud)
格式你可以直接写'yyyy-MM-dd HH:mm:ss'或另外一种方法
private function escDates() {
return 'yyyy-MM-dd HH:mm:ss';
}
Run Code Online (Sandbox Code Playgroud)
希望这给你一个想法.