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.
我已将后端的日期格式设置为 dd/mm/yy,使用 en_GB 语言环境.但是我仍然得到美国日期格式.我如何获得英国日期格式?
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屋!
查看全文