Magento - 如何添加返回DD/MM/YY而不是MM/DD/YY的前端日期选择器?

ʍǝɥ*_*ʇɐɯ 6 magento

在我的表格中,我有:

<?php echo $this->__('Date') ?>: 
<input type="text" name="cal_date" id="cal_date" value="" /> 
<img title="Select date" id="cal_date_trig" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'adminhtml/default/default/images/grid-cal.gif'; ?>"  class="v-middle"/>
Run Code Online (Sandbox Code Playgroud)

这显示日历.

在标题中我有:

<reference name="head">
        <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
        <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
        <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
</reference>
Run Code Online (Sandbox Code Playgroud)

这会加载js和css.

在布局xml我有:

<block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
Run Code Online (Sandbox Code Playgroud)

当我在我的模板中包含它时,这会将日历选择器添加到页面:

<?php echo $this->getChildHtml('html_calendar') ?>
Run Code Online (Sandbox Code Playgroud)

我没有错误,日期选择器工作.

我已使用en_GB语言环境将后端的日期格式设置为dd/mm/yy.但是我仍然获得美国日期格式.我怎样才能获得英国日期格式?

Jev*_*nov 7

您可以在表单上放置日历,如下所示:

<input type="text" name="date_to" id="date_to" value="" /> 
<input type="text" name="date_from" id="date_from" value="" />

<script type="text/javascript">// <![CDATA[
Calendar.setup({
    inputField : 'date_from',
    ifFormat : '%m/%e/%y',
    button : 'date_from_trig',
    align : 'Bl',
    singleClick : true
});

Calendar.setup({
    inputField : 'date_to',
    ifFormat : '%m/%e/%y',
    button : 'date_to_trig',
    align : 'Bl',
    singleClick : true
});
// ]]></script>
Run Code Online (Sandbox Code Playgroud)

  • 您还必须在输入后输入按钮触发器(date_from_trig或date_to_trig):`<img rel="nofollow noreferrer" src ="<?php echo $ this-> getSkinUrl('images/grid-cal.gif')?> "class ="v-middle"id ="date_from_trig"/>` (4认同)