我正在使用Bootstrap datatimepicker(https://eonasdan.github.io/bootstrap-datetimepicker/)。它很棒,但它没有显示或让用户选择秒。
$(document).ready(function () {
$('#datetimepicker1').datetimepicker({defaultDate: new Date()});
});
<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>
那么如何选择秒?以及如何以格式显示秒数?目前它是05/18/2017 1:26 PM
,我想要05/18/2017 1:26:40 PM
在dev guide中,有一个fillSeconds()
函数,但我不知道如何在此处应用它。
答案 0 :(得分:5)
将format设置为moment和sideBySide正确的值:
$('#datetimepicker1').datetimepicker({
defaultDate: new Date(),
format: 'DD/MM/YYYY hh:mm:ss A',
sideBySide: true
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
<link rel="stylesheet"
href="https://rawgit.com/Eonasdan/bootstrap-datetimepicker/master/build/css/bootstrap-datetimepicker.min.css">
<script src="https://rawgit.com/Eonasdan/bootstrap-datetimepicker/master/build/js/bootstrap-datetimepicker.min.js"></script>
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<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>
</div>
</div>
</div>
</div>
答案 1 :(得分:0)
$(document).ready(function () {
$('#datetimepicker1').datetimepicker({
defaultDate: new Date()});
}).fillseconds();
试试这种方式。