如何更改datepicker日期格式?

时间:2011-04-07 20:02:13

标签: javascript xul

默认情况下,datepicker的格式是MM / DD / YYYY,我希望它是DD / MM / YYYY,有没有办法改变它?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

如果您无法将区域设置更改为DD / MM / YYYY,则可以尝试对datepicker绑定进行子类化并覆盖_init方法。您需要设置以下属性:

this._separatorFirst.value = '/';
this._separatorSecond.value = '/';
this.dayField = document.getAnonymousElementByAttribute(this, "anonid", "input-one");
this.monthField = document.getAnonymousElementByAttribute(this, "anonid", "input-two");
this.yearField = document.getAnonymousElementByAttribute(this, "anonid", "input-three");
this.yearField.parentNode.className = "datetimepicker-input-subbox datetimepicker-year";
this.yearField.size = 4;
this.yearField.maxLength = 4;
this.yearLeadingZero = true;
this.monthLeadingZero = true;
this.dayLeadingZero = true;
this._fieldAMPM.parentNode.collapsed = true;

另外,请考虑提交增强请求以覆盖具有属性和/或属性的格式。

相关问题