在我的网站中,使用Bootstrap 4,我有一个完美的工作日期选择器实例,给我一个日历来选择日期。但是,我想修改它以使用时间。我已经尝试了很多不同版本的日期时间选择器,并将CDN文件按正确顺序排列,但出于某种原因,某些内容存在冲突。
我希望有人能够指出我使用datetimepicker的最佳方式,或者只是将时间与此相结合,以适合我现在使用的方式。
这是工作日期选择器的代码:
$('#datepicker').datepicker({
weekStart: 1,
daysOfWeekHighlighted: "6,0",
autoclose: true,
todayHighlight: true,
});
$('#datepicker').datepicker("setDate", new Date());

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js"></script>
<h6>Set New Expiration: <input data-date-format="mm/dd/yyyy" id="datepicker" name="datepicker"></h6>
&#13;
答案 0 :(得分:1)
您可以使用AuspeXeu DateTimePicker。它还支持键盘导航。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/AuspeXeu/bootstrap-datetimepicker/master/js/bootstrap-datetimepicker.js"></script>
<link href="https://rawgit.com/AuspeXeu/bootstrap-datetimepicker/master/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<input class="datepicker" type="text">
<button onclick="showDate()">Get Date</button>
&#13;
{
resolve: {
alias: {
'jquery': 'jquery/jquery', // -> node_modules/jquery/jquery.js
// ...
},
},
amd: {
jQuery: true
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery', // legacy code tend to use $ without requiring it
jQuery: 'jquery'
}),
// ...
]
}
&#13;