DateTimePicker time picker in 24 hour but displaying in 12hr?

前端 未结 13 1222
孤独总比滥情好
孤独总比滥情好 2021-02-02 09:17

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 f

相关标签:
13条回答
  • 2021-02-02 10:12

    this will display current ate & time. Working on my side perfectly

    $("#datePicker").datetimepicker({
        format: 'DD-MM-YYYY HH:mm A',
        defaultDate: new Date(),
    });
    
    0 讨论(0)
  • 2021-02-02 10:13

    Just this!

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

    i use v4 and work well!!

    0 讨论(0)
  • 2021-02-02 10:13

    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 '
        });
    });
    
    0 讨论(0)
  • 2021-02-02 10:15

    The catch is that hh is for format 12 hours and HH is for 24 hours.

    24 hour format

    $(function () {
        $('#customElement').datetimepicker({
            format: 'HH:mm',           
        });
    });
    

    12 hour format

    $(function () {
        $('#customElement').datetimepicker({
            format: 'hh:mm',           
        });
    });
    
    0 讨论(0)
  • 2021-02-02 10:19

    'DD/MM/YYYY hh:mm A' => 12 hours 'DD/MM/YYYY HH:mm A' => 24 hours

    0 讨论(0)
  • 2021-02-02 10:20

    To show the correct 24H format, for example, only put

    $(function () {
        $('#date').datetimepicker({
             format: 'DD/MM/YYYY HH:mm',
        });
    
    });
    
    0 讨论(0)
提交回复
热议问题