【问题标题】:How to change date format (MM/DD/YY) to (DD/MM/YYYY) in date picker如何在日期选择器中将日期格式 (MM/DD/YY) 更改为 (DD/MM/YYYY)
【发布时间】:2018-08-24 18:54:39
【问题描述】:
this.locale = {
        direction: 'ltr',
        format: moment.localeData().longDateFormat('L'),
        separator: ' - ',
        applyLabel: 'Apply',
        cancelLabel: 'Cancel',
        weekLabel: 'W',
        customRangeLabel: 'Custom Range',
        daysOfWeek: moment.weekdaysMin(),
        monthNames: moment.monthsShort(),
        firstDay: moment.localeData().firstDayOfWeek()
    };

现在日期格式是 MM/DD/YYYY。如何将日期格式更改为 DD-MM-YYYY

【问题讨论】:

标签: javascript jquery


【解决方案1】:

使用 Datepicker 的 dateFormat 选项:

$( ".selector" ).datepicker({
  dateFormat: "dd-mm-yy"
});

更多使用说明和所有不同格式选项的链接可以在这里找到:http://api.jqueryui.com/datepicker/#option-dateFormat

【讨论】:

    猜你喜欢
    • 2011-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    • 2012-03-05
    • 2022-11-19
    相关资源
    最近更新 更多