twitter-bootstrap 24 小时格式的日期范围选择器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36373626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 23:49:25  来源:igfitidea点击:

Date Range Picker in 24 hour format

javascriptjquerytwitter-bootstrapbootstrap-daterangepicker

提问by Arvind

I am using the Date Range Pickerplugin for bootstrap and I am trying to get the values in 24hour format. I have set the option timePicker24Hour: truebut it still doesn't return it in 24 hour format.

我正在使用日期范围选择器插件进行引导,并且我正在尝试以 24 小时格式获取值。我已经设置了该选项,timePicker24Hour: true但它仍然没有以 24 小时格式返回它。

This is my code:

这是我的代码:

$("#reportdatetime").daterangepicker({
    timePicker: true,
    timePicker24Hour: true,
    timePickerIncrement: 30,
    locale: {
        format: 'MM/DD/YYYY h:mm'
    }
});

Fiddle: https://jsfiddle.net/rdawkins/k67xfa1g/1/

小提琴:https: //jsfiddle.net/rdawkins/k67xfa1g/1/

回答by Arvind

Use the correct locale format.To display time in 24 hours format use the following -

使用正确的语言环境格式。要以 24 小时格式显示时间,请使用以下内容 -

$("#reportdatetime").daterangepicker({
    timePicker: true,
    timePicker24Hour: true,
    timePickerIncrement: 30,
    locale: {
        format: 'MM/DD/YYYY H:mm'
    }
});

working example : https://jsfiddle.net/Ly0jh5pz/2

工作示例:https: //jsfiddle.net/Ly0jh5pz/2

回答by Hirendrasinh S. Rathod

<script>
    $('#datepicker').daterangepicker({
        "timePicker": true,
        "timePicker24Hour": true,
        "startDate": "03/27/2016",
        "endDate": "04/02/2016"
        });
    });
</script>

回答by sssD

you can set AM/PM format into it if you want: hereis some examples. Andhereis describing how to use moment formats.

如果需要,您可以将 AM/PM 格式设置为:这里有一些示例。而这里描述的是如何使用时刻格式。