I’ve read some opened issue about this, but it didn’t help me. I have also read the moment.js
documentation but I don’t know why it still not working. I just want to add the seconds
to show when picking a datetime. Please see my code below:
$(function(){
$('#dateTimePicker').datetimepicker({
format: "DD/MM/YYYY hh:mm:ss A"
});
});
<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/3.1.4/css/bootstrap-datetimepicker.min.css">
<input type="text" id="dateTimePicker" class="form-control">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.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/moment.js/2.20.1/moment-with-locales.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/3.1.4/js/bootstrap-datetimepicker.min.js"></script>
3
Answers
Please try this snippet,
Setting the format to the correct value from moment and sideBySide:
For more info please visit this – How to add seconds to Bootstrap date time picker
Bootstrap3 DateTime picker – https://eonasdan.github.io/bootstrap-datetimepicker/Options/#viewdate
Try passing
useSeconds: true
as shown below. That should help.The datetimepicker FAQ says that it uses the format option to decide what components to show. But then I found
useMinutes
anduseSeconds
options here: http://eonasdan.github.io/bootstrap-datetimepicker/Changelog/#2120.(I know its not a very good place to document a feature, but …. let it be 😉 )