DateTimePicker time picker in 24 hour but displayi

2019-03-10 19:50发布

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            
    });
});

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>

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

10条回答
等我变得足够好
2楼-- · 2019-03-10 20:35

You can also use the parameters "use24hours" and "language" to do this, as follows:

$(function () {
    $('.datetime').datetimepicker({
        language: 'pt-br',
        use24hours: true,
    });
});

查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-10 20:37

Just this!

$(function () {
    $('#date').datetimepicker({
         format: 'H:m',
    });

});

i use v4 and work well!!

查看更多
何必那么认真
4楼-- · 2019-03-10 20:38

I don't understand why the other friends tell you use HH, But after I test so many time, The correct 24 hour format is :

hh

.

I see it from : http://www.malot.fr/bootstrap-datetimepicker/

I don't know why they don't use the common type HH for 24 hour.....

I hope anyone could tell me if I'm wrong.....

查看更多
贼婆χ
5楼-- · 2019-03-10 20:38

With seconds!

$('.Timestamp').datetimepicker({
    format: 'DD/MM/YYYY HH:mm:ss'
});

To skip future dates:

$(function () {
    var date = new Date();
    var currentMonth = date.getMonth();
    var currentDate = date.getDate();
    var currentYear = date.getFullYear();
    $('#datetimepicker,#datetimepicker1').datetimepicker({
        pickTime: false,
        format: "DD-MM-YYYY",  
        maxDate: new Date(currentYear, currentMonth, currentDate + 1)
    });
});
查看更多
戒情不戒烟
6楼-- · 2019-03-10 20:41

Meridian pertains to AM/PM, by setting it to false you're indicating you don't want AM/PM, therefore you want 24-hour clock implicitly.

$('#timepicker1').timepicker({showMeridian:false});
查看更多
走好不送
7楼-- · 2019-03-10 20:46

I know it's been quite some time since the question was asked. However, if it helps anyone this worked for me.

 $(function() {
    $('.datetimepicker').datetimepicker({
        format: 'MM-DD-YYYY HH:mm '
    });
});
查看更多
登录 后发表回答