Using 24 hour time in bootstrap timepicker

前端 未结 15 877
太阳男子
太阳男子 2020-12-03 13:55

Hi im using http://eonasdan.github.io/bootstrap-datetimepicker/ on bootstrap, specifically example number 4.

I added this property to take away the PM thing and be a

相关标签:
15条回答
  • 2020-12-03 14:18
    <input type="text" name="time" data-provide="timepicker"  id="time" class="form-control" placeholder="Start Time" value="" />
    
    
    $('#time').timepicker({
            timeFormat: 'H:i',
            'scrollDefaultNow'      : 'true',
            'closeOnWindowScroll'   : 'true',
            'showDuration'          : false,
            'ignoreReadonly'        : true,
    
    })
    

    work for me.

    0 讨论(0)
  • 2020-12-03 14:21
    "YYYY-MM-DD HH:mm:ss" => 24 hours format;
    
    "YYYY-MM-DD hh:mm:ss" => 12 hours format;
    

    the difference is letter 'H'

    0 讨论(0)
  • 2020-12-03 14:22

    And this works for me:

    $(function () {
        $('#datetimepicker5').datetimepicker({
            format: 'HH:mm'
        });
    });
    
    0 讨论(0)
  • 2020-12-03 14:22

    The below code is correct answer for me.

     $('#datetimepicker6').datetimepicker({
                        format : 'YYYY-MM-DD HH:mm'
                    });
    
    0 讨论(0)
  • 2020-12-03 14:23

    To pick only time with 24 hr time format, use

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

    If you want to pick 24 hr time format with date also, use

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

    Example :

    $(function() {
      $('#datetimepicker1').datetimepicker({
                format: 'HH:mm'
      });
      
      $('#datetimepicker2').datetimepicker({
                format: 'MM/DD/YYYY HH:mm'
      });
      $('#datetimepicker3').datetimepicker({
          format: 'hh:mm A',
      });
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">
    
    <div class="container">
      <div class="row">
        <div class='col-sm-6'>
          <div class="form-group">
            <span>Select 24 hour time format</span>
            <div class='input-group date' id='datetimepicker1'>
              <input type='text' class="form-control" />
              <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
              </span>
            </div>
            <br/>
            <span>Select time with Date</span>
            <div class='input-group date' id='datetimepicker2'>
              <input type='text' class="form-control" />
              <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
              </span>
            </div>
            <br/>
            <span>Select 12 hour time format</span>
            <div class='input-group date' id='datetimepicker3'>
              <input type='text' class="form-control" />
              <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
              </span>
            </div>
          </div>
        </div>
      </div>
    </div>

    For more info

    0 讨论(0)
  • 2020-12-03 14:24

    This will surely help on bootstrap timepicker

    format :"DD:MM:YYYY HH:mm"
    
    0 讨论(0)
提交回复
热议问题