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

前端 未结 13 1221
孤独总比滥情好
孤独总比滥情好 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 09:59

    Perfectly worked for me

    jQuery('#datetimepicker1').datetimepicker({
        use24hours: true,   
        format: "YYYY-MM-DD HH:mm ",
        defaultDate: new Date(),
        });
    
    0 讨论(0)
  • 2021-02-02 10:00

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

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

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

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

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

    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)
        });
    });
    
    0 讨论(0)
  • 2021-02-02 10:07
    $(function () {
        $('#startTime, #endTimeContent').datetimepicker({
            format: 'HH:mm',
            pickDate: false,
            pickSeconds: false,
            pick12HourFormat: false            
        });
    });
    

    your selector seems to be wrong,please check it

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

    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});
    
    0 讨论(0)
提交回复
热议问题