【问题标题】:Override dateFormat in existing jQuery UI DatePicker覆盖现有 jQuery UI DatePicker 中的 dateFormat
【发布时间】:2018-12-07 21:23:54
【问题描述】:

由于插件非常广泛,我不想弄乱核心文件来更改dateFormat。在替代脚本中调用 dateFormat 不会带来任何更改,因此我正在寻找替代解决方案。这是我的情况:

基于this thread and answer,我想将现有的dd-mm-yy datepicker 格式更改为d MM 格式。我不得不使用前面提到的来源,用 jQuery 从日期选择器和输入字段中隐藏年份:

jQuery('#user_birthday').datepicker({
    beforeShow: function (input, inst) {
        inst.dpDiv.addClass('no-year-shown');
    },
    onClose: function(dateText, inst){
        inst.dpDiv.removeClass('no-year-shown');
    }
});

这个伟大的解决方案消失了,但是结果例如:December\07,而原始显示的日期格式是07-12-2018。我如何覆盖它,所以它是7 December(欧盟格式)。

【问题讨论】:

    标签: jquery jquery-ui-datepicker date-format


    【解决方案1】:

    如何使用 DateFormat 选项:

    $( "#user_birthday" ).datepicker({ dateFormat: "dd-MM" });

    【讨论】:

    • 我的意思是除了 css 隐藏。但是,如果您结合使用它,我什么也没说。
    猜你喜欢
    • 2010-10-18
    • 1970-01-01
    • 2010-10-27
    • 2017-09-08
    • 1970-01-01
    • 2010-11-02
    • 1970-01-01
    • 1970-01-01
    • 2013-01-30
    相关资源
    最近更新 更多