Magento-如何添加返回DD/MM/YY而不是MM/DD/YY的前端日期选择器? [英] Magento - How do I add a frontend date picker that returns DD/MM/YY instead of MM/DD/YY?
本文介绍了Magento-如何添加返回DD/MM/YY而不是MM/DD/YY的前端日期选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的表格中,我有:
<?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"/>
这显示日历.
在标题中,我有:
<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>
这将加载js和CSS.
This loads the js and css.
在布局xml中,我有:
In the layout xml I have:
<block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
当我将其添加到模板中时,这会将日历选择器添加到页面中:
This adds the calendar picker to the page when I include this in my template:
<?php echo $this->getChildHtml('html_calendar') ?>
我没有收到任何错误,日期选择器也可以正常工作.
I get no errors and the date picker works.
我已将en_GB语言环境的后端日期格式设置为dd/mm/yy.但是我仍在获取美国日期格式.如何获得英国日期格式?
I have set the date format in the backend to dd/mm/yy with en_GB locale. However I am still getting US date formats. How can I get UK date formats?
推荐答案
您可以将日历放在这样的表单上:
You can place calendar on the form like this:
<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>
这篇关于Magento-如何添加返回DD/MM/YY而不是MM/DD/YY的前端日期选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文