易于使用日期时间选择器

时间:2017-12-07 03:01:31

标签: css twitter-bootstrap bootstrap-datetimepicker

我正在寻找一款易于使用的日期时间选择器。我尝试使用bootstrap日期时间选择器,我使用bootstrap 4 alpha。它对我不起作用。

这是我的代码:

    <script>
    $(function() {
        $('#datetimepicker1').datetimepicker();
    });
    </script>
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
   <!-- Moment JS -->
    <script type="text/javascript" src="<?php echo $ROOT; ?>js/moment.min.js"></script>
    <!--Bootstrap JS -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" ></script>
    <!-- dateTimePicker JS -->
    <script type="text/javascript" src="<?php echo $ROOT; ?>js/bootstrap-datetimepicker.min.js"></script>
    <!--bootstrap  -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
    <!-- dateTimePicker CSS -->
    <link rel="stylesheet" type="text/css" href="<?php echo $ROOT; ?>css/bootstrap-datetimepicker.min.css"> 

    <div class = "form-group col col-md-4 col-sm-4 col-12">
        <div class='input-group date' id='datetimepicker1'>
          <input type='text' class="form-control" id="servDate"/>
          <span class="input-group-addon">
            <span class="glyphicon glyphicon-calendar"></span>
          </span>
        </div>
    </div>

3 个答案:

答案 0 :(得分:1)

我建议使用:https://tempusdominus.github.io/bootstrap-4/这是DateTimePicker的 Bootstrap 4 版本(Eonasdan / bootstrap-datetimepicker的继承者)。

您可以在文档中找到示例:https://tempusdominus.github.io/bootstrap-4/Usage/

Github回购:https://github.com/tempusdominus/bootstrap-4

然而,这是一个来自tempusdominus docs的工作片段(最佳视图扩展片段):

&#13;
&#13;
$(function () {
    $('#datetimepicker1').datetimepicker();
});
&#13;
<script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" crossorigin="anonymous">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.0/moment-with-locales.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script src="https://rawgit.com/tempusdominus/bootstrap-4/master/build/js/tempusdominus-bootstrap-4.min.js"></script>
<link href="https://rawgit.com/tempusdominus/bootstrap-4/master/build/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">


<div class="container">
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <div class="input-group date" id="datetimepicker1" data-target-input="nearest">
                    <input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
                    <span class="input-group-addon" data-target="#datetimepicker1" data-toggle="datetimepicker">
                        <span class="fa fa-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
    </div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

使用稳定的库,可能你不知道测试版中的bug在哪里;) 试试这个

<script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<!-- Moment JS -->
<script type="text/javascript" src="//momentjs.com/downloads/moment.js"></script>
<!--Bootstrap JS -->
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<!-- dateTimePicker JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<!-- bootstrap  -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<!-- dateTimePicker CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<script>
$(function() {
    $('#datetimepicker1').datetimepicker();
});
</script>
<div class = "form-group col col-md-4 col-sm-4 col-12">
    <div class='input-group date' id='datetimepicker1'>
        <input type='text' class="form-control" id="servDate"/>
        <span class="input-group-addon">
            <span class="glyphicon glyphicon-calendar"></span>
        </span>
    </div>
</div>

可能会有点帮助^ _ ^

答案 2 :(得分:-1)

尝试使用Bootstrap 3。 找到了一些有用的链接:https://eonasdan.github.io/bootstrap-datetimepicker/ 希望这会有所帮助。

相关问题