DateTimePicker时间选择器在24小时内显示在12小时内? [英] DateTimePicker time picker in 24 hour but displaying in 12hr?

查看:930
本文介绍了DateTimePicker时间选择器在24小时内显示在12小时内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 http://eonasdan.github.io/bootstrap-datetimepicker/,并且运行良好,但存在一个问题.我刚刚有一个选择器设置:

I'm using the bootstrap ready date time picker from http://eonasdan.github.io/bootstrap-datetimepicker/ and it's working nicely but for one issue. I have a picker setup just from time as so:

$(function () {
    $('#startTime, #endTime').datetimepicker({
        format: 'hh:mm',
        pickDate: false,
        pickSeconds: false,
        pick12HourFormat: false            
    });
});

这会将选择器设置为24小时,因此我可以选择19:00作为时间.但是,当我选择这次时,它在输入框中显示为07:00.这是显示选择器的设置:

This sets the picker to 24 hour so I can select 19:00 as a time. But when I choose this time it displays as 07:00 in the input box. Here is the setup displaying the picker:

    <div class="input-group date timePicker" id="endTime">
        <input type='text' class="form-control" readonly="true"
            id="endTimeContent" /> <span class="input-group-addon"><span
            class="glyphicon glyphicon-time"></span> </span>
    </div>

输入框中是否可以使用24小时的特定数据格式?

Is there a specific data-format I can use for 24 hour in the input box?

推荐答案

因为选择器脚本正在使用 moment.js 来解析格式字符串,您可以在此处阅读文档以获取正确的格式字符串.

Because the picker script is using moment.js to parse the format string, you can read the docs there for proper format strings.

但是在24小时内,请使用HH而不是hh格式.

But for 24Hr time, use HH instead of hh in the format.

$(function () {
    $('#startTime, #endTime').datetimepicker({
        format: 'HH:mm',
        pickDate: false,
        pickSeconds: false,
        pick12HourFormat: false            
    });
});

这篇关于DateTimePicker时间选择器在24小时内显示在12小时内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆