如何更改日期选择器日期格式?

发布于 2024-10-30 22:21:30 字数 140 浏览 5 评论 0原文

默认情况下,datepicker 的格式是 MM/DD/YYYY,我想要它是DD/MM/YYYY,有办法改变吗?

By default, the datepicker's format is MM/DD/YYYY, I would like it to be DD/MM/YYYY, is there a way to change it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

慈悲佛祖 2024-11-06 22:21:30

如果您无法将区域设置更改为 DD/MM/YYYY,您可以尝试对日期选择器绑定进行子类化并覆盖 _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;

还可以考虑提交增强请求以使用特性和/或属性覆盖格式。

If you can't change your locale settings to DD/MM/YYYY, you could try subclassing the datepicker binding and overriding the _init method. You need to set the following properties:

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;

Also consider filing an enhancement request to override the format with an attribute and/or property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文